FileDocCategorySizeDatePackage
RemovedEntityTest.javaAPI DocHibernate 3.2.51493Tue Dec 12 16:22:26 GMT 2006org.hibernate.test.jpa.removed

RemovedEntityTest

public class RemovedEntityTest extends org.hibernate.test.jpa.AbstractJPATest
author
Steve Ebersole

Fields Summary
Constructors Summary
public RemovedEntityTest(String name)

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

		return new FunctionalTestClassTestSuite( RemovedEntityTest.class );
	
public voidtestRemoveThenContains()

		Session s = openSession();
		s.beginTransaction();
		Item item = new Item();
		item.setName( "dummy" );
		s.persist( item );
		s.getTransaction().commit();
		s.close();

		s = openSession();
		s.beginTransaction();
		s.delete( item );
		boolean contains = s.contains( item );
		s.getTransaction().commit();
		s.close();

		assertFalse( "expecting removed entity to not be contained", contains );
	
public voidtestRemoveThenGet()

		Session s = openSession();
		s.beginTransaction();
		Item item = new Item();
		item.setName( "dummy" );
		s.persist( item );
		s.getTransaction().commit();
		s.close();

		Long id = item.getId();

		s = openSession();
		s.beginTransaction();
		s.delete( item );
		item = ( Item ) s.get( Item.class, id );
		s.getTransaction().commit();
		s.close();

		assertNull( "expecting removed entity to be returned as null from get()", item );