HHH-5267 : Added FailureExpected test for updating one-to-one mapped as delete-orphan while detached
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19959 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
03f6f7fdd8
commit
457f2a9d60
|
@ -89,4 +89,44 @@ public class DeleteOneToOneOrphansTest extends FunctionalTestCase {
|
||||||
|
|
||||||
cleanupData();
|
cleanupData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testOrphanedWhileDetachedFailureExpected() {
|
||||||
|
createData();
|
||||||
|
|
||||||
|
Session session = openSession();
|
||||||
|
session.beginTransaction();
|
||||||
|
List results = session.createQuery( "from EmployeeInfo" ).list();
|
||||||
|
assertEquals( 1, results.size() );
|
||||||
|
results = session.createQuery( "from Employee" ).list();
|
||||||
|
assertEquals( 1, results.size() );
|
||||||
|
Employee emp = ( Employee ) results.get( 0 );
|
||||||
|
assertNotNull( emp.getInfo() );
|
||||||
|
|
||||||
|
//only fails if the object is detached
|
||||||
|
session.getTransaction().commit();
|
||||||
|
session.close();
|
||||||
|
session = openSession();
|
||||||
|
session.beginTransaction();
|
||||||
|
|
||||||
|
emp.setInfo( null );
|
||||||
|
|
||||||
|
//save using the new session (this used to work prior to 3.5.x)
|
||||||
|
session.saveOrUpdate(emp);
|
||||||
|
|
||||||
|
session.getTransaction().commit();
|
||||||
|
session.close();
|
||||||
|
|
||||||
|
session = openSession();
|
||||||
|
session.beginTransaction();
|
||||||
|
emp = ( Employee ) session.get( Employee.class, emp.getId() );
|
||||||
|
assertNull( emp.getInfo() );
|
||||||
|
results = session.createQuery( "from EmployeeInfo" ).list();
|
||||||
|
assertEquals( 0, results.size() );
|
||||||
|
results = session.createQuery( "from Employee" ).list();
|
||||||
|
assertEquals( 1, results.size() );
|
||||||
|
session.getTransaction().commit();
|
||||||
|
session.close();
|
||||||
|
|
||||||
|
cleanupData();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue