hibernate-orm
hibernate-orm copied to clipboard
HHH-16627 Duplicate records being created for many-to-many relation implemented as two one-to-many relations with cascading + HHH-16628 Two transactions within the same session cause unsaved transient instance error
https://hibernate.atlassian.net/browse/HHH-16627
https://hibernate.atlassian.net/browse/HHH-16628
Hi@sebersole, I found a problem that my solution does not fix, given:
Student s1 = session.createQuery( "from Student where name = :name", Student.class )
.setParameter( "name", STUDENT_NAME ).uniqueResult();
Course c1 = session.createQuery( "from Course where name = :name", Course.class )
.setParameter( "name", COURSE_1_NAME ).uniqueResult();
Enrollment e1 = new Enrollment( 10 );
s1.addEnrollment( e1 );
c1.addEnrollment( e1 );
Student mergedStudent = session.merge( s1 );
Course mergedCourse = session.merge( c1 );
the second merge trigger the persist of a second Enrollment , working on this and I'll check also if we can clear the mergedEntities after flush().
Thanks for looking at it!