Why even after I rollback a transaction the auto-increment field (in this
case is MySQL) keeps the value inserted?
Shouldn't be removed after rollback?
public boolean save(T obj) throws HorusDAOException {
EntityTransaction transaction = this.manager.getTransaction();
transaction.begin();
try {
this.manager.persist(obj);
transaction.commit();
} catch (RuntimeException ex) {
if (transaction.isActive()) {
try {
transaction.rollback();
} catch (RuntimeException e) {
}
}
throw new HorusDAOException(ex);
} finally {
manager.close();
}
return true;
}
In this case the insert is not performed because there is a duplicated key,
so I rollback and I expected to not increment the auto-increment counter for
the auto-increment field.
What am I doing wrong here?
--
View this message in context: http://old.nabble.com/Why-auto-increment-field-keeps-value-after-rollback--tp26843209p26843209.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.