FileDocCategorySizeDatePackage
ImmutableNaturalIdTest.javaAPI DocHibernate 3.2.51504Wed Jun 06 16:33:32 BST 2007org.hibernate.test.naturalid.immutable

ImmutableNaturalIdTest

public class ImmutableNaturalIdTest extends org.hibernate.junit.functional.FunctionalTestCase
{@inheritDoc}
author
Steve Ebersole

Fields Summary
Constructors Summary
public ImmutableNaturalIdTest(String string)

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

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

		return new FunctionalTestClassTestSuite( ImmutableNaturalIdTest.class );
	
public voidtestUpdate()

		// prepare some test data...
		Session session = openSession();
    	session.beginTransaction();
	  	User user = new User();
    	user.setUserName( "steve" );
    	user.setEmail( "steve@hibernate.org" );
    	user.setFirstName( "Steve" );
    	user.setInitial( null);
    	user.setLastName( "Ebersole" );
    	user.setPassword( "brewhaha" );
		session.save( user );
    	session.getTransaction().commit();
    	session.close();

		// 'user' is now a detached entity, so lets change a property and reattch...
		user.setPassword( "homebrew" );
		session = openSession();
		session.beginTransaction();
		session.update( user );
		session.getTransaction().commit();
		session.close();

		// clean up
		session = openSession();
		session.beginTransaction();
		session.delete( user );
		session.getTransaction().commit();
		session.close();