Announcement Announcement Module
No announcement yet.
Transaction noRollbackFor Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction noRollbackFor


    i try to do the following:

    while (true) {
      try {
        UniqueKey k = uniqueKeyDao.findNextVersionKey();
        versionDao.persist(new Version(k));
      } catch (EntityExistsException e) {
        logger.debug("Rollback ? : "+TransactionAspectSupport.currentTransactionStatus().isRollbackOnly());
    I want to loop until this methods succeeds. Normaly it will succeed at the first try. But when there are millions of concurrent transactions, it could be that another instance persists the version before this one did it.... long story...

    The only thing i want to know is why
    	public Version persist(Version entity) {
    		return entity;
    is not working as supposed. I tried all kind of Exceptions. All Exceptions that are thrown or can be thrown of this dao method MUST NOT setRollbackOnly... but it still does.
    I tried a way to unset an set rollbackOnly Property, but haven't found one.

    Regards, Tobias

  • #2
    I justed read rhe following:

    However, note that this will only work as long as all participating resources are capable of continuing towards a transaction commit even after a data access failure: This is generally not the case for a Hibernate Session, for example; neither is it for a sequence of JDBC insert/update/delete operations.

    Is there a known workaround for Hibernate ? If not i can trash my idea...


    • #3
      Your solution seems like a patchy one and it is an issue which imho should be resolved by setting the correct transaction ISOLATION level.

      Also, I have to check I admit, is that for RuntimeExceptions always a rollback will occur (as specified by the specification).