HHH-18458 - Remove deprecated org.hibernate.EmptyInterceptor

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2024-09-10 18:17:00 +02:00 committed by Jan Schatteman
parent 01b3a2210f
commit 30f2a2045d
11 changed files with 9 additions and 42 deletions

View File

@ -26,11 +26,6 @@ include::{example-dir-event}/InterceptorTest.java[tags=events-interceptors-examp
----
====
[NOTE]
====
You can either implement `Interceptor` directly or extend the `org.hibernate.EmptyInterceptor` base class.
====
An Interceptor can be either `Session`-scoped or `SessionFactory`-scoped.
A Session-scoped interceptor is specified when a session is opened.

View File

@ -1,26 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate;
import java.io.Serializable;
import org.hibernate.metamodel.RepresentationMode;
import org.hibernate.type.Type;
/**
* An interceptor that does nothing. May be used as a base class for application-defined custom interceptors.
*
* @author Gavin King
*
* @deprecated implement {@link Interceptor} directly
*/
@Deprecated(since = "6.0")
public class EmptyInterceptor implements Interceptor, Serializable {
protected EmptyInterceptor() {}
}

View File

@ -14,9 +14,7 @@ import org.hibernate.type.Type;
/**
* An interceptor that does nothing.
* This is an internal class and should not be used as a base to implement a custom Interceptor;
* it is similar to the public, deprecated {@link org.hibernate.EmptyInterceptor} but overrides
* the default methods for sake of efficiency: this wasn't possible on the original deprecated
* copy as that wouldn't have been backwards compatible. For this reason this copy is internal.
* it overrides the default methods for sake of efficiency.
*
* Implementors of Interceptor don't need a base class anymore since we now have default
* implementations of the contract defined in the interface.

View File

@ -18,7 +18,7 @@ public class CollectionInterceptor implements Interceptor {
return false;
}
public boolean onSave(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types) {
public boolean onPersist(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types) {
( (User) entity ).getActions().add("created");
return false;
}

View File

@ -180,7 +180,7 @@ public class InterceptorTest extends BaseCoreFunctionalTestCase {
Session s = openSession(
new Interceptor() {
@Override
public boolean onSave(
public boolean onPersist(
Object entity,
Object id,
Object[] state,

View File

@ -22,7 +22,7 @@ public class PropertyInterceptor implements Interceptor {
}
@Override
public boolean onSave(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types) {
public boolean onPersist(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types) {
state[2] = Calendar.getInstance();
return true;
}

View File

@ -23,7 +23,7 @@ public class StatefulInterceptor implements Interceptor {
private List list = new ArrayList();
@Override
public boolean onSave(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types) {
public boolean onPersist(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types) {
if ( !(entity instanceof Log) ) {
list.add( new Log( "insert", (String) id, entity.getClass().getName() ) );
}

View File

@ -35,7 +35,7 @@ public class DocumentInterceptor implements Interceptor {
}
}
public boolean onSave(
public boolean onPersist(
Object entity,
Object id,
Object[] state,

View File

@ -34,7 +34,7 @@ public class ExceptionInterceptor implements Interceptor {
}
@Override
public boolean onSave(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
public boolean onPersist(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
throws CallbackException {
if (allowSave) return false;
throw new IllegalStateException( EXCEPTION_MESSAGE );

View File

@ -20,7 +20,7 @@ public class LocalExceptionInterceptor extends ExceptionInterceptor {
public static final String LOCAL_EXCEPTION_MESSAGE = "Session-scoped interceptor enabled";
@Override
public boolean onSave(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
public boolean onPersist(Object entity, Object id, Object[] state, String[] propertyNames, Type[] types)
throws CallbackException {
if (allowSave) return false;
throw new IllegalStateException( LOCAL_EXCEPTION_MESSAGE );

View File

@ -35,7 +35,7 @@ public class DocumentInterceptor implements Interceptor {
}
}
public boolean onSave(
public boolean onPersist(
Object entity,
Object id,
Object[] state,