Methods Summary |
---|
public java.lang.String[] | getMappings()
return new String[] { "version/PersonThing.hbm.xml" };
|
public static junit.framework.Test | suite()
return new FunctionalTestClassTestSuite( VersionTest.class );
|
public void | testCollectionNoVersion()
Session s = openSession();
Transaction t = s.beginTransaction();
Person gavin = new Person("Gavin");
new Task("Code", gavin);
s.persist(gavin);
t.commit();
s.close();
assertEquals(0, gavin.getVersion());
s = openSession();
t = s.beginTransaction();
gavin = (Person) s.createCriteria(Person.class).uniqueResult();
new Task("Document", gavin);
t.commit();
s.close();
assertEquals(0, gavin.getVersion());
assertFalse( Hibernate.isInitialized( gavin.getTasks() ) );
s = openSession();
t = s.beginTransaction();
gavin = (Person) s.createCriteria(Person.class).uniqueResult();
gavin.getTasks().clear();
t.commit();
s.close();
assertEquals(0, gavin.getVersion());
assertTrue( Hibernate.isInitialized( gavin.getTasks() ) );
s = openSession();
t = s.beginTransaction();
s.delete(gavin);
t.commit();
s.close();
|
public void | testCollectionVersion()
Session s = openSession();
Transaction t = s.beginTransaction();
Person gavin = new Person("Gavin");
new Thing("Passport", gavin);
s.persist(gavin);
t.commit();
s.close();
assertEquals(0, gavin.getVersion());
s = openSession();
t = s.beginTransaction();
gavin = (Person) s.createCriteria(Person.class).uniqueResult();
new Thing("Laptop", gavin);
t.commit();
s.close();
assertEquals(1, gavin.getVersion());
assertFalse( Hibernate.isInitialized( gavin.getThings() ) );
s = openSession();
t = s.beginTransaction();
gavin = (Person) s.createCriteria(Person.class).uniqueResult();
gavin.getThings().clear();
t.commit();
s.close();
assertEquals(2, gavin.getVersion());
assertTrue( Hibernate.isInitialized( gavin.getThings() ) );
s = openSession();
t = s.beginTransaction();
s.delete(gavin);
t.commit();
s.close();
|
public void | testVersionShortCircuitFlush()
Session s = openSession();
Transaction t = s.beginTransaction();
Person gavin = new Person("Gavin");
new Thing("Passport", gavin);
s.persist(gavin);
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
Thing passp = (Thing) s.get(Thing.class, "Passport");
passp.setLongDescription("blah blah blah");
s.createQuery("from Person").list();
s.createQuery("from Person").list();
s.createQuery("from Person").list();
t.commit();
s.close();
assertEquals( passp.getVersion(), 1 );
s = openSession();
t = s.beginTransaction();
s.createQuery("delete from Thing").executeUpdate();
s.createQuery("delete from Person").executeUpdate();
t.commit();
s.close();
|