This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Hibernate JPA not persisting!!

Dec 27th, 2011, 05:13 AM

Hi all,
I am trying to use JPA and hibernate for the first time. So, forgive me if this is a silly question. I have a Spring MVC application and I plan to use JPA Hibernate on the DAO layer. I am a connecting to MySQL server.

With the current code, I am able to do the select operation with no issues at all. But I am not able to persist any new object or make changes to the existing objects.

Can somebody identify my mistakes? I did search and found post related but, it looks like I have already fixed those issues. Here is my code and configurations:

Don't catch exceptions that breaks proper tx management. Also your datasource is useless as you already configured connection properties in the persistence.xml and you aren't referencing the datasource for your entitymanagerfactory.

Judging from your code you also use component-scanning to scan for beans. So my guess is you are running into problems from that and that is by scanning the same object twice (leading to duplicate beans one proxied one not proxied for transactions (the latter is probably used by your controllers).