1 package org.hibernate.test.orphan; 3 4 import junit.framework.Test; 5 import junit.framework.TestSuite; 6 7 import org.hibernate.Session; 8 import org.hibernate.Transaction; 9 import org.hibernate.test.TestCase; 10 11 12 17 public class PropertyRefTest extends TestCase { 18 19 public PropertyRefTest(String name) { 20 super( name ); 21 } 22 23 protected String [] getMappings() { 24 return new String [] { 25 "orphan/User.hbm.xml", 26 "orphan/Mail.hbm.xml" 27 }; 28 } 29 30 public void testDeleteParentWithBidirOrphanDeleteCollectionBasedOnPropertyRef() { 31 Session session = openSession(); 32 Transaction txn = session.beginTransaction(); 33 User user = new User( "test" ); 34 user.addMail( "test" ); 35 user.addMail( "test" ); 36 session.save( user ); 37 txn.commit(); 38 session.close(); 39 40 session = openSession(); 41 txn = session.beginTransaction(); 42 user = ( User ) session.load( User.class, user.getId() ); 43 session.delete( user ); 44 txn.commit(); 45 session.close(); 46 47 session = openSession(); 48 txn = session.beginTransaction(); 49 session.createQuery( "delete from Mail where alias = :alias" ).setString( "alias", "test" ).executeUpdate(); 50 session.createQuery( "delete from User where userid = :userid" ).setString( "userid", "test" ).executeUpdate(); 51 txn.commit(); 52 session.close(); 53 } 54 55 public static Test suite() { 56 return new TestSuite(PropertyRefTest.class); 57 } 58 59 } 60 | Popular Tags |