FileDocCategorySizeDatePackage
PropertyRefTest.javaAPI DocHibernate 3.2.51555Tue Dec 12 16:22:26 GMT 2006org.hibernate.test.orphan

PropertyRefTest

public class PropertyRefTest extends org.hibernate.junit.functional.FunctionalTestCase
Test for HHH-565
author
Steve Ebersole

Fields Summary
Constructors Summary
public PropertyRefTest(String name)

		super( name );
	
Methods Summary
public java.lang.String[]getMappings()

		return new String[] { "orphan/User.hbm.xml", "orphan/Mail.hbm.xml" };
	
public static junit.framework.Testsuite()

		return new FunctionalTestClassTestSuite( PropertyRefTest.class );
	
public voidtestDeleteParentWithBidirOrphanDeleteCollectionBasedOnPropertyRef()

		Session session = openSession();
		Transaction txn = session.beginTransaction();
		User user = new User( "test" );
		user.addMail( "test" );
		user.addMail( "test" );
		session.save( user );
		txn.commit();
		session.close();

		session = openSession();
		txn = session.beginTransaction();
		user = ( User ) session.load( User.class, user.getId() );
		session.delete( user );
		txn.commit();
		session.close();

		session = openSession();
		txn = session.beginTransaction();
		session.createQuery( "delete from Mail where alias = :alias" ).setString( "alias", "test" ).executeUpdate();
		session.createQuery( "delete from User where userid = :userid" ).setString( "userid", "test" ).executeUpdate();
		txn.commit();
		session.close();