FileDocCategorySizeDatePackage
PartiallyGeneratedComponentTest.javaAPI DocHibernate 3.2.52057Fri Jan 19 05:55:08 GMT 2007org.hibernate.test.generated

PartiallyGeneratedComponentTest

public class PartiallyGeneratedComponentTest extends org.hibernate.junit.functional.DatabaseSpecificFunctionalTestCase
{@inheritDoc}
author
Steve Ebersole

Fields Summary
Constructors Summary
public PartiallyGeneratedComponentTest(String string)

		super( string );
	
Methods Summary
public booleanappliesTo(org.hibernate.dialect.Dialect dialect)

		return dialect instanceof Oracle9Dialect;
	
public java.lang.String[]getMappings()

		return new String[] { "generated/ComponentOwner.hbm.xml" };
	
public static junit.framework.Testsuite()

		return new FunctionalTestClassTestSuite( PartiallyGeneratedComponentTest.class );
	
public voidtestPartialComponentGeneration()

		ComponentOwner owner = new ComponentOwner( "initial" );
		Session s = openSession();
		s.beginTransaction();
		s.save( owner );
		s.getTransaction().commit();
		s.close();

		assertNotNull( "expecting insert value generation", owner.getComponent() );
		int previousValue = owner.getComponent().getGenerated();
		assertFalse( "expecting insert value generation", 0 == previousValue );

		s = openSession();
		s.beginTransaction();
		owner = ( ComponentOwner ) s.get( ComponentOwner.class, owner.getId() );
		assertEquals( "expecting insert value generation", previousValue, owner.getComponent().getGenerated() );
		owner.setName( "subsequent" );
		s.getTransaction().commit();
		s.close();

		assertNotNull( owner.getComponent() );
		previousValue = owner.getComponent().getGenerated();

		s = openSession();
		s.beginTransaction();
		owner = ( ComponentOwner ) s.get( ComponentOwner.class, owner.getId() );
		assertEquals( "expecting update value generation", previousValue, owner.getComponent().getGenerated() );
		s.delete( owner );
		s.getTransaction().commit();
		s.close();