FileDocCategorySizeDatePackage
DeleteTest.javaAPI DocHibernate 3.2.52169Tue Dec 12 16:22:26 GMT 2006org.hibernate.test.ops

DeleteTest

public class DeleteTest extends AbstractOperationTestCase
{@inheritDoc}
author
Steve Ebersole

Fields Summary
Constructors Summary
public DeleteTest(String name)

		super( name );
	
Methods Summary
public static junit.framework.Testsuite()

		return new FunctionalTestClassTestSuite( DeleteTest.class );
	
public voidtestDeleteVersionedWithCollectionNoUpdate()

		// test adapted from HHH-1564...
		Session s = openSession();
		s.beginTransaction();
		VersionedEntity c = new VersionedEntity( "c1", "child-1" );
		VersionedEntity p = new VersionedEntity( "root", "root");
		p.getChildren().add( c );
		c.setParent( p );
		s.save( p );
		s.getTransaction().commit();
		s.close();

		clearCounts();

		s = openSession();
		s.beginTransaction();
        VersionedEntity loadedParent = ( VersionedEntity ) s.get( VersionedEntity.class, "root" );
        s.delete( loadedParent );
		s.getTransaction().commit();
        s.close();

		assertInsertCount( 0 );
		assertUpdateCount( 0 );
		assertDeleteCount( 2 );
	
public voidtestNoUpdateOnDelete()

		Session s = openSession();
        s.beginTransaction();
		Node node = new Node( "test" );
		s.persist( node );
		s.getTransaction().commit();
		s.close();

		clearCounts();

		s = openSession();
		s.beginTransaction();
		s.delete( node );
		s.getTransaction().commit();
		s.close();

		assertUpdateCount( 0 );
		assertInsertCount( 0 );
	
public voidtestNoUpdateOnDeleteWithCollection()

		Session s = openSession();
        s.beginTransaction();
		Node parent = new Node( "parent" );
		Node child = new Node( "child" );
		parent.getCascadingChildren().add( child );
		s.persist( parent );
		s.getTransaction().commit();
		s.close();

		clearCounts();

		s = openSession();
		s.beginTransaction();
		parent = ( Node ) s.get( Node.class, "parent" );
		s.delete( parent );
		s.getTransaction().commit();
		s.close();

		assertUpdateCount( 0 );
		assertInsertCount( 0 );
		assertDeleteCount( 2 );