Author | Message |
---|---|
talisunep
Posts: 140
|
Posted 03:28 May 10, 2013 |
professor my spring not commiting form values to database like on adding a new user, do i need to do a entityManager.flush(); after merge in DAOimplementation? return entityManager.merge(user); my add user fileds are not showing up in my database and i dont get any errors after hitting the submit button it redirects to the redirected page. Is this a case where the queries are still not committed due to some JPA configuration? where do you think i could be going wrong as i have checked the repository code and i seem to do the code right...? |
cysun
Posts: 2935
|
Posted 08:13 May 10, 2013 |
The saveUser() method looks fine. Do a little debugging to see if it was actually called. |
talisunep
Posts: 140
|
Posted 08:15 May 10, 2013 |
in this case since i am not getting any errors to debug what do you think will be the best way to go about debugging to see if my method has been implemented? |
talisunep
Posts: 140
|
Posted 08:26 May 10, 2013 |
i re-did the class example done in class... everything was done as per the class lecture but its still not updating the postgres database... |
cysun
Posts: 2935
|
Posted 08:27 May 10, 2013 |
If the method is indeed called, then it must have something to do with transaction management. Since you do have the @Transactional annotation, so check a) if you imported the correct annotation (should be org.springframework.transaction.annotation.Transactional), and b) if you have <tx:annotation-driven /> in applicationContext.xml (without it @Transactional will be ignored). |
cysun
Posts: 2935
|
Posted 08:30 May 10, 2013 |
Check out the springmvc example from the repository (the pieces tag) and run it. If it works, your postgresql db is fine. |
talisunep
Posts: 140
|
Posted 13:39 May 10, 2013 |
professor i checked a.the correct annotation is imported... org.springframework.transaction.annotation.Transactional b. also the c. i also did logging statement in the method on the controller/userDao/userDao Implementation System.out.println(user.getFirstName()+"from jpa"); @Override public User saveUser(User user) { i still cant figure out why it wont commit to the database..? Do you think that i am still missing some configuration in my SPRING set up?
|
cysun
Posts: 2935
|
Posted 15:33 May 10, 2013 |
Have you tried the springmvc code? If the sample code works, it means there's something wrong with your Spring bean files; if it doesn't work, then maybe there's something wrong with PostgreSQL. I remember somebody had some weird problem with MySQL on MAC in CS320 (was that you?), and restarting the computer fixed it. |
talisunep
Posts: 140
|
Posted 15:40 May 10, 2013 |
the springmvc code also has the same issue..it reads the values from the database but it cant write(merge) values into the database like the example i state above.. |
cysun
Posts: 2935
|
Posted 15:45 May 10, 2013 |
If save used to work but all of sudden stopped working, then I can't really help you other than suggesting that you reinstall PostgreSQL. If save never worked (or you never tried before), it may have something to do with the JDBC driver. Try an older version of the driver (i.e. change the dependency) and see if it fixes the problem. |
talisunep
Posts: 140
|
Posted 20:06 May 10, 2013 |
i reinstalled postgre on my mac.. re set up the database Last edited by talisunep at
20:08 May 10, 2013.
|
talisunep
Posts: 140
|
Posted 20:08 May 10, 2013 |
also wanted to mention that the input values from .GET are printing out values of add user till the .merge method in the userDao implementatton... |