Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

309
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda