i am trying to do a cascade insert using hibernate with jpa. Here are my DO classes.
if i try to persist these do's like this.....
where person is....
i am getting the following exception.
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: INSERT on table 'ADDRESS' caused a violation of foreign key constraint 'FK1ED033D4A2C3AF45' for key (9). The statement has been rolled back.
can you please help me understanding the mapping? can anyone tell me what am i missing here?
OCP Java SE 6 Programmer, OCP Java EE 5 Web Component Developer, OCE Java EE 6 Web Services Developer, VMware Certified Core Spring 3.x Developer, EMC Proven Professional (ISM-V2)
What is foreign key constraint 'FK1ED033D4A2C3AF45' for key (9) ? I don't see any reason why this would not run. I would initialize the address list and use add rather than set the whole list, but despite that what you have should insert 2 rows in Address and one row in Person. Maybe post your ddl.
Actually when i run this program in Derby DB, its creating new Foreign key constraints in Address table. I dont know why it is doing this. i will run this program for MS-Sql and try to analyse the problem. I will update soon.