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

  • Pessimistic Retry

    We are having some trouble with a pessimistic retrier.

    We are using hibernate for our database manager.

    We have a save method that has an afterReturning advice applied to it that calls a method that sets the permissions for the object being saved and any other associated objects that does not have permissions set. The pessimistic retrier for dealing with pessimistic errors is applied to the method that applies the permissions to the saved object.

    The problem we are running into is that the when a pessimistic error is thrown, the database changes that occurred in the save method are rolled back, but the pessimistic retrier only restarts at the method applying the permissions. So when the method applying the permissions finishes, the changes in the save method are no longer there because of the rollback.

    We need the pessimistic retrier on the permissions method because this is where the pessimistic errors are occurring when the spring security updateAcl method is called.

    We were able to keep the rollback from happening when the pessimistic error was thrown by adding +org.springframework.dao.PessimisticLockingFailure Exception to the transactionAttributes in our TransactionProxyFactor definition.

    What happened though was Hibernate never committed the changes to the database.

    So we manually tried to commit the changes by sending the transactionManager into the Pessimisitic Retrier, but we kept getting the following error:

    Pre-bound JDBC Connection found! HibernateTransactionManager does not support
    running within DataSourceTransactionManager if told to manage the DataSource
    itself. It is recommended to use a single HibernateTransactionManager for all
    transactions on a single DataSource, no matter whether Hibernate or JDBC
    access.

    I know one way might be to turn off the auto commit completely, but I can imagine that will be a pain because we need to commit every database transaction.

    Is there a way to commit the save transaction in the pessimistic retrier or get hibernate to auto commit the transaction after the method to create the permissions regardless of a pessimistic error?
Working...
X