public void testSequenceTransactional2() {
logger.log(BasicLevel.DEBUG, "***************testSequenceTransactional2*****************");
PersistenceManager pm = pmf.getPersistenceManager();
pm.getObjectIdClass(Cow.class);
//get the sequence
Sequence s = pm.getSequence(COW_SEQ_TRANSACTIONAL);
assertNotNull("Sequence " + COW_SEQ_TRANSACTIONAL + " should not be null.", s);
//begin the tx
pm.currentTransaction().begin();
Cow c1 = new Cow("cowSeqNC1", ((Long)s.next()).longValue());
Cow c2 = new Cow("cowSeqNC2", ((Long)s.next()).longValue());
Cow c3 = new Cow("cowSeqNC3", ((Long)s.next()).longValue());
assertTrue(c1.getNbOfLegs() < c2.getNbOfLegs());
assertTrue(c2.getNbOfLegs() < c3.getNbOfLegs());
Collection c = new ArrayList();
c.add(c1);
c.add(c2);
c.add(c3);
//make persistent
pm.makePersistentAll(c);
pm.currentTransaction().commit();
//begin a tx
pm.currentTransaction().begin();
Cow c4 = new Cow("cowSeqNC4", ((Long)s.next()).longValue());
//keep the number
long index = c4.getNbOfLegs();
pm.makePersistent(c4);
//rollback
pm.currentTransaction().rollback();
//begin a tx
pm.currentTransaction().begin();
//check the next number generated is not the one used for the rollback : gap
assertTrue(((Long)s.next()).longValue() != index);
pm.currentTransaction().commit();
pm.close();
}