Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

306
Views
Is there a replacement for Isolater (Hibernate 3.6) in Hibernate 4.x and above?

I have been using Isolater (org.hibernate.engine.transaction.Isolater) from Hibernate 3.6 in order to be able to do work outside of a transaction.

I have to upgrade to Hibernate 4.3 or above and Isolater is no longer there in this version of hibernate. Is there any substitute to performing isolated work after this change in hibernate?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

There is a replacement in Hibernate 4 and 5 but it seems like it is not really intended to be used outside of the Hibernate internals.

You need access to a SessionImplementor so you'll have to cast your Session to that. I can't find a way to get access that doesn't involve casting the result of getCurrentSession(). Then you can use the TransactionCoordinator to create an IsolationDelegate which works similarly to Isolater:

    SessionImplementor session = (SessionImplementor) sessionFactory.getCurrentSession();
    IsolationDelegate isolationDelegate = session.getTransactionCoordinator().createIsolationDelegate();
    isolationDelegate.delegateWork(new AbstractWork() {
        @Override
        public void execute(Connection connection) throws SQLException {
            // This will run on a separate connection with the current
            // transaction suspended (if necessary)
        }
    }, false);
over 4 years ago · Santiago Trujillo Report

0

One thing you can do is use the Hibernate action queue to register a specific callback that fires right before the commit or immediately after depending on your use case. Those classes are:

org.hibernate.action.spi.BeforeTransactionCompletionProcess org.hibernate.action.spi.AfterTransactionCompletionProcess

For your use case, it seems you would want to use an AfterTransactionCompletionProcess. In order to register the callback with a specific session you would:

session.getActionQueue().registerProcess( 
  new AfterTransactionCompletionProcess() {
    @Override
    void doAfterTransactionCompletion(
      boolean success, 
      SharedSessionContractImplementor session) {
      // do your logic here
    }
  } 
);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!