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.