I can hardly believe that. Please show your code.
okay. this is extracted from my JUnit tests. the SESSION is built and destroed in the JUnit test's setup and teardown methods.
public void testCreateExistsLoginEditAndDeleteSubscriber() {
logger.debug("testing rollback");
Transaction tx = null;
try {
tx = SESSION.beginTransaction();
// create
Subscriber me = new Subscriber("Testing","Test",TEST_USERNAME,TEST_PASSWORD);
me.setEmail("
[email protected]");
Long id = SubscriberPeer.save(SESSION,me);
// force an error to get it to abort.
assertNull("id was null.",id);
// snip out irrelevent code
tx.commit();
} catch (Error er) {
// abort the transaction.
logger.error("caught an error: "+er.getMessage());
try {
if (tx != null) {
logger.debug("rolling back transaction after an error");
tx.rollback();
}
} catch (HibernateException he) {
logger.error("HibernateException while aborting transaction. "+
he.getMessage());
}
throw er;
} catch (Exception ex) {
// abort the transaction.
logger.error("caught an exception: "+ex.getMessage());
try {
if (tx != null) {
logger.debug("rolling back transaction after an exception");
tx.rollback();
}
} catch (HibernateException he) {
logger.error("HibernateException while aborting transaction. "+
he.getMessage());
}
}
}
after the abort the test user I have created is still hanging around in the database.