TimestampTestpublic class TimestampTest extends org.hibernate.junit.functional.FunctionalTestCase
Constructors Summary |
---|
public TimestampTest(String str)
super(str);
|
Methods Summary |
---|
public void | configure(org.hibernate.cfg.Configuration cfg)
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
| public java.lang.String[] | getMappings()
return new String[] { "timestamp/User.hbm.xml" };
| public static junit.framework.Test | suite()
return new FunctionalTestClassTestSuite( TimestampTest.class );
| public void | testComponent()
Session s = openSession();
Transaction t = s.beginTransaction();
User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") );
s.persist(u);
s.flush();
u.getPerson().setCurrentAddress("Peachtree Rd");
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
u = (User) s.get(User.class, "gavin");
u.setPassword("$ecret");
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
u = (User) s.get(User.class, "gavin");
assertEquals( u.getPassword(), "$ecret" );
s.delete(u);
t.commit();
s.close();
| public void | testUpdateFalse()
getSessions().getStatistics().clear();
Session s = openSession();
Transaction t = s.beginTransaction();
User u = new User( "gavin", "secret", new Person("Gavin King", new Date(), "Karbarook Ave") );
s.persist(u);
s.flush();
u.getPerson().setName("XXXXYYYYY");
t.commit();
s.close();
assertEquals( 1, getSessions().getStatistics().getEntityInsertCount() );
assertEquals( 0, getSessions().getStatistics().getEntityUpdateCount() );
s = openSession();
t = s.beginTransaction();
u = (User) s.get(User.class, "gavin");
assertEquals( u.getPerson().getName(), "Gavin King" );
s.delete(u);
t.commit();
s.close();
assertEquals( 1, getSessions().getStatistics().getEntityDeleteCount() );
|
|