Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

401
Vistas
Hibernate Interceptor not working after upgrading to Hibernate 5

Earlier my Interceptor code was working fine for Hibernate 3. After I upgraded to Hibernate 5 and made the necessary changes, callback methods like onSave & onFlushDirty stopped working.

Regarding library changes, below Hibernate 3 jars I replaced with Hibernate 5 jars.

Hibernate 3 jars replaced-

  • dom4j.jar
  • hibernate-core-4.3.5.Final.jar
  • hibernate-jpa-2.1-api-1.0.0.Final.jar
  • jboss-logging.jar

Hibernate 5 jars added-

  • byte-buddy-1.9.5.jar
  • classmate-1.3.4.jar
  • dom4j-2.1.1.jar
  • hibernate-commons-annotations-5.1.0.Final.jar
  • hibernate-core-5.4.1.Final.jar
  • javax.persistence-api-2.2.jar
  • javax.transaction.jar
  • jboss-logging-3.3.2.Final.jar

Below is my Interceptor code-

public class CustomInterceptor extends EmptyInterceptor {

@Override
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) {
    System.out.println("onFlushDirty called");
    return super.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
}

@Override
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
    System.out.println("onSavecalled");
    return super.onSave(entity, id, state, propertyNames, types);
}
}

If someone can point out what I am missing or any correction that I need to make, it would be very helpful.

Please Note- Entire Application is working smoothly except that Interceptor Callback methods are not getting called.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Could you please try with the following:

Session session = sessionFactory.withOptions()
                  .interceptor(new CustomInterceptor())
                  .openSession();
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda