EmptyInterceptor is deprecated in Hibernate 6 and gone in Hibernate 7
Fix it fast
Most common cause, 1 of 3The class still extends EmptyInterceptor
Replace extends EmptyInterceptor with implements Interceptor and keep only the methods you need.
import org.hibernate.Interceptor;
public class AuditInterceptor implements Interceptor {
// override only the callbacks you use
}
# application.properties
spring.jpa.properties.hibernate.session_factory.interceptor=com.example.AuditInterceptorShort answer
EmptyInterceptor has been deprecated since Hibernate 6.0 and was removed in 7.0, so on Spring Boot 4 the class no longer compiles. Implement org.hibernate.Interceptor directly, since its methods now have defaults. If the old class overrode onPrepareStatement to change SQL, move that code to a StatementInspector. Applies to Hibernate 6.6 and 7.4.
Which cause do you have?
Check which Hibernate ORM version the build resolves, then list the interceptor methods your class overrides. The version tells you whether EmptyInterceptor still exists; the method names tell you which of the causes apply.
./mvnw dependency:tree -Dincludes=org.hibernate.orm:hibernate-core
grep -rn "EmptyInterceptor\|onPrepareStatement\|Serializable id" src/main/javaThen find the line you see in this list and open its fix:
- 1The class still extends EmptyInterceptor
Hibernate 6.x compiles with a deprecation warning; Hibernate 7.x fails with cannot find symbol for EmptyInterceptor - 2onPrepareStatement was used to rewrite SQL
The @Override on onPrepareStatement(String sql) fails with does not override or implement a method from a supertype - 3Overridden callbacks still take a Serializable id
On Hibernate 7, methods like onSave or onFlushDirty with a Serializable id parameter no longer compile
What does the error look like?
EmptyInterceptor in org.hibernate has been deprecatedcannot find symbol symbol: class EmptyInterceptordoes not override or implement a method from a supertype
Cause 1 of 3
The class still extends EmptyInterceptor
You seeHibernate 6.x compiles with a deprecation warning; Hibernate 7.x fails with cannot find symbol for EmptyInterceptor
Check
EmptyInterceptor carries @Deprecated(since="6.0") in Hibernate 6, so extending it compiles with a warning. The Hibernate 7.0 migration guide then lists the class as removed, because org.hibernate.Interceptor now gives every method a default body. An upgrade to Spring Boot 4, which brings Hibernate 7, turns the warning into a compile error.
grep -rn "extends EmptyInterceptor" src/main/javaFix
Replace extends EmptyInterceptor with implements Interceptor and keep only the methods you need. Register it with the hibernate.session_factory.interceptor setting, which Spring Boot passes through from spring.jpa.properties.
import org.hibernate.Interceptor;
public class AuditInterceptor implements Interceptor {
// override only the callbacks you use
}
# application.properties
spring.jpa.properties.hibernate.session_factory.interceptor=com.example.AuditInterceptorVerify
The build compiles with no EmptyInterceptor warning, and the interceptor still runs on a save in a test.
./mvnw -q compileConfirmed by docs.jboss.org
Cause 2 of 3
onPrepareStatement was used to rewrite SQL
You seeThe @Override on onPrepareStatement(String sql) fails with does not override or implement a method from a supertype
Check
A class that changed SQL in onPrepareStatement breaks after the upgrade because the Interceptor in Hibernate 6.6 and 7.x has no such method any more. Hibernate 5 had already deprecated it with the note to supply a StatementInspector instead. StatementInspector has one method, inspect(String sql), which may return a different SQL string.
grep -rn "onPrepareStatement" src/main/javaFix
Move the body of onPrepareStatement into a StatementInspector and register it with hibernate.session_factory.statement_inspector. An inspector set this way is shared by all sessions, so keep it thread-safe.
import org.hibernate.resource.jdbc.spi.StatementInspector;
public class SqlCommentInspector implements StatementInspector {
@Override
public String inspect(String sql) {
return "/* app=shop */ " + sql;
}
}
# application.properties
spring.jpa.properties.hibernate.session_factory.statement_inspector=com.example.SqlCommentInspectorVerify
With spring.jpa.properties.hibernate.show_sql=true in the test configuration, the logged statements carry your change.
./mvnw -q testConfirmed by docs.jboss.org
Cause 3 of 3
Overridden callbacks still take a Serializable id
You seeOn Hibernate 7, methods like onSave or onFlushDirty with a Serializable id parameter no longer compile
Check
Hibernate 6.0 changed entity identifiers in Interceptor callbacks from Serializable to Object, and 7.0 removed the old Serializable versions of onLoad, onSave, onFlushDirty, onDelete and the others. In 7.4 onSave itself is deprecated, and the javadoc points to onPersist.
grep -rn "Serializable id" src/main/javaFix
Change the id parameter to Object and rename onSave to onPersist and onDelete to onRemove. Return true from onPersist or onFlushDirty only when you changed the state array.
@Override
public boolean onPersist(Object entity, Object id, Object[] state,
String[] propertyNames, Type[] types) {
// set created-at or similar fields in state[]
return true;
}Verify
The class compiles without override errors and the callback fires when a test persists an entity.
./mvnw -q testConfirmed by docs.jboss.org
How do I stop it coming back?
- Compile with -Xlint:deprecation in CI so Hibernate deprecations show up a major version before the removal.
- Read the Hibernate migration guide for each major version before bumping Spring Boot, since Boot 4 moves Hibernate from 6.6 to 7.x.
- Keep SQL rewriting in a StatementInspector and entity callbacks in an Interceptor, so each piece follows one stable API.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Dispatch Pro.