Link to home
Start Free TrialLog in
Avatar of AshwinKRaj
AshwinKRajFlag for United States of America

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
Avatar of Mick Barry
Mick Barry
Flag of Australia image

ASKER CERTIFIED SOLUTION
Avatar of AshwinKRaj
AshwinKRaj
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AshwinKRaj

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.