AshwinKRaj
asked on
How do I persist a One-to-Many relationship using Hibernate 3.5, JPA 2 and Spring 3 @MVC?
I am using Hibernate 3.5.6 + Hibernate JPA 2.0 in a Spring MVC 3.0.3 web application context. I have a one-to-many relationship modeled (similar to below). The parent and associated child instances are supposed to get persisted to the database. However, with either consistently formed data or if made inconsistent (say, by null out a single non-nullable property e.g. Child.childName of a single record to reproduce a database exception), two bad things happen:
* Inconsistent data set is persisted, up to the point of violating data
* Data set is not persisted at all
Please download the ZIP file from the related post in the Spring community forum:
http://forum.springsource.org/attachment.php?attachmentid=3273&d=1287675066
This ZIP file contains:
This app runs in tcServer developer edition and Tomcat, but both with the same behavior. Once you add the required JAR libraries to the WAR file, the application will run in a JSP/Java Servlet compliant app server. Let me know what I am missing. I consider myself a novice with Hibernate, so ORM related aspects in Spring are far from being my forte at this point!
Thanks.
Ashwin
* Inconsistent data set is persisted, up to the point of violating data
* Data set is not persisted at all
Please download the ZIP file from the related post in the Spring community forum:
http://forum.springsource.org/attachment.php?attachmentid=3273&d=1287675066
This ZIP file contains:
This app runs in tcServer developer edition and Tomcat, but both with the same behavior. Once you add the required JAR libraries to the WAR file, the application will run in a JSP/Java Servlet compliant app server. Let me know what I am missing. I consider myself a novice with Hibernate, so ORM related aspects in Spring are far from being my forte at this point!
Thanks.
Ashwin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No one checked the code I had referenced, so the other answers were only reference pointers as opposed to a resolution-style answer. Eventually, I got help outside of Experts Exchange recently, and posted a follow up to close my own question.
http://www.springbyexample.org/examples/one-to-many-jpa-hibernate-config-jpa-entity-config.html