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:
Gail Badner 2010-07-15 23:47:32 +00:00
parent 03f6f7fdd8
commit 457f2a9d60
1 changed files with 40 additions and 0 deletions

View File

@ -89,4 +89,44 @@ public class DeleteOneToOneOrphansTest extends FunctionalTestCase {
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();
}
}