HHH-18539 remove Session.load()

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-08-29 10:37:07 +02:00
parent e407c53c86
commit bbbaf511ec
7 changed files with 1 additions and 209 deletions

View File

@ -476,115 +476,6 @@ public interface Session extends SharedSessionContract, EntityManager {
*/
void evict(Object object);
/**
* Return the persistent instance of the given entity class with the given identifier,
* obtaining the specified lock mode, assuming the instance exists.
* <p>
* Convenient form of {@link #load(Class, Object, LockOptions)}.
*
* @param theClass a persistent class
* @param id a valid identifier of an existing persistent instance of the class
* @param lockMode the lock level
*
* @return the persistent instance or proxy
*
* @see #load(Class, Object, LockOptions)
*
* @deprecated use {@link #get(Class, Object, LockMode)}
*/
@Deprecated(since = "6.0")
<T> T load(Class<T> theClass, Object id, LockMode lockMode);
/**
* Return the persistent instance of the given entity class with the given identifier,
* obtaining the specified lock mode, assuming the instance exists.
*
* @param theClass a persistent class
* @param id a valid identifier of an existing persistent instance of the class
* @param lockOptions contains the lock level
* @return the persistent instance or proxy
*
* @deprecated use {@link #get(Class, Object, LockOptions)}
*/
@Deprecated(since = "6.0")
<T> T load(Class<T> theClass, Object id, LockOptions lockOptions);
/**
* Return the persistent instance of the given entity class with the given identifier,
* obtaining the specified lock mode, assuming the instance exists.
* <p>
* Convenient form of {@link #load(String, Object, LockOptions)}.
*
* @param entityName the entity name
* @param id a valid identifier of an existing persistent instance of the class
* @param lockMode the lock level
*
* @return the persistent instance or proxy
*
* @see #load(String, Object, LockOptions)
*
* @deprecated use {@link #get(String, Object, LockMode)}
*/
@Deprecated(since = "6.0")
Object load(String entityName, Object id, LockMode lockMode);
/**
* Return the persistent instance of the given entity class with the given identifier,
* obtaining the specified lock mode, assuming the instance exists.
*
* @param entityName the entity name
* @param id a valid identifier of an existing persistent instance of the class
* @param lockOptions contains the lock level
*
* @return the persistent instance or proxy
*
* @deprecated use {@link #get(String, Object, LockOptions)}
*/
@Deprecated(since = "6.0")
Object load(String entityName, Object id, LockOptions lockOptions);
/**
* Return the persistent instance of the given entity class with the given identifier,
* making the assumption that the instance exists in the database. This method might
* return a proxied instance that is initialized on-demand, when a non-identifier method
* is accessed.
* <p>
* You should not use this method to determine if an instance exists in the database
* (use {@code get()} instead). Use this only to retrieve an instance that you assume
* exists, where non-existence would be an actual error.
* <p>
* This operation is very similar to {@link #getReference(Class, Object)}.
*
* @param theClass a persistent class
* @param id a valid identifier of an existing persistent instance of the class
*
* @return the persistent instance or proxy
*
* @deprecated use {@link #getReference(Class, Object)}
*/
@Deprecated(since = "6.0")
<T> T load(Class<T> theClass, Object id);
/**
* Return the persistent instance of the given entity class with the given identifier,
* making the assumption that the instance exists in the database. This method might
* return a proxied instance that is initialized on-demand, when a non-identifier
* method is accessed.
* <p>
* You should not use this method to determine if an instance exists in the database
* (use {@code get()} instead). Use this only to retrieve an instance that you assume
* exists, where non-existence would be an actual error.
*
* @param entityName the entity name
* @param id a valid identifier of an existing persistent instance of the class
*
* @return the persistent instance or proxy
*
* @deprecated use {@link #getReference(String, Object)}
*/
@Deprecated(since = "6.0")
Object load(String entityName, Object id);
/**
* Read the persistent state associated with the given identifier into the given
* transient instance.

View File

@ -37,11 +37,9 @@ import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.event.spi.EventManager;
import org.hibernate.event.spi.DeleteContext;
import org.hibernate.event.spi.EventSource;
import org.hibernate.event.spi.MergeContext;
import org.hibernate.event.spi.PersistContext;
import org.hibernate.event.spi.RefreshContext;
import org.hibernate.graph.RootGraph;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.jdbc.ReturningWork;
@ -812,36 +810,6 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
delegate.evict( object );
}
@Override
public <T> T load(Class<T> theClass, Object id, LockMode lockMode) {
return delegate.load( theClass, id, lockMode );
}
@Override
public <T> T load(Class<T> theClass, Object id, LockOptions lockOptions) {
return delegate.load( theClass, id, lockOptions );
}
@Override
public Object load(String entityName, Object id, LockMode lockMode) {
return delegate.load( entityName, id, lockMode );
}
@Override
public Object load(String entityName, Object id, LockOptions lockOptions) {
return delegate.load( entityName, id, lockOptions );
}
@Override
public <T> T load(Class<T> theClass, Object id) {
return delegate.load( theClass, id );
}
@Override
public Object load(String entityName, Object id) {
return delegate.load( entityName, id );
}
@Override
public void load(Object object, Object id) {
delegate.load( object, id );

View File

@ -186,42 +186,6 @@ public class SessionLazyDelegator implements Session {
this.lazySession.get().evict( object );
}
@Override
@Deprecated
public <T> T load(Class<T> theClass, Object id, LockMode lockMode) {
return this.lazySession.get().load( theClass, id, lockMode );
}
@Override
@Deprecated
public <T> T load(Class<T> theClass, Object id, LockOptions lockOptions) {
return this.lazySession.get().load( theClass, id, lockOptions );
}
@Override
@Deprecated
public Object load(String entityName, Object id, LockMode lockMode) {
return this.lazySession.get().load( entityName, id, lockMode );
}
@Override
@Deprecated
public Object load(String entityName, Object id, LockOptions lockOptions) {
return this.lazySession.get().load( entityName, id, lockOptions );
}
@Override
@Deprecated
public <T> T load(Class<T> theClass, Object id) {
return this.lazySession.get().load( theClass, id );
}
@Override
@Deprecated
public Object load(String entityName, Object id) {
return this.lazySession.get().load( entityName, id );
}
@Override
public void load(Object object, Object id) {
this.lazySession.get().load( object, id );

View File

@ -66,4 +66,5 @@ public interface EventSource extends SessionImplementor {
// ordering is improved.
void removeOrphanBeforeUpdates(String entityName, Object child);
Object load(String entityName, Object identifier);
}

View File

@ -1405,8 +1405,6 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
return procedureCall;
}
protected abstract Object load(String entityName, Object identifier);
@Override
public ExceptionConverter getExceptionConverter() {
if ( exceptionConverter == null ) {

View File

@ -945,11 +945,6 @@ public class SessionImpl
fireLoad( new LoadEvent( id, object, this, getReadOnlyFromLoadQueryInfluencers() ), LoadEventListener.RELOAD );
}
@Override @Deprecated
public <T> T load(Class<T> entityClass, Object id) throws HibernateException {
return this.byId( entityClass ).getReference( id );
}
@Override @Deprecated
public Object load(String entityName, Object id) throws HibernateException {
return this.byId( entityName ).getReference( id );
@ -1056,26 +1051,6 @@ public class SessionImpl
}
}
@Override @Deprecated
public <T> T load(Class<T> entityClass, Object id, LockMode lockMode) throws HibernateException {
return this.byId( entityClass ).with( new LockOptions( lockMode ) ).getReference( id );
}
@Override @Deprecated
public <T> T load(Class<T> entityClass, Object id, LockOptions lockOptions) throws HibernateException {
return this.byId( entityClass ).with( lockOptions ).getReference( id );
}
@Override @Deprecated
public Object load(String entityName, Object id, LockMode lockMode) throws HibernateException {
return this.byId( entityName ).with( new LockOptions( lockMode ) ).getReference( id );
}
@Override @Deprecated
public Object load(String entityName, Object id, LockOptions lockOptions) throws HibernateException {
return this.byId( entityName ).with( lockOptions ).getReference( id );
}
@Override
public <T> T get(Class<T> entityClass, Object id, LockMode lockMode) throws HibernateException {
return this.byId( entityClass ).with( new LockOptions( lockMode ) ).load( id );

View File

@ -881,11 +881,6 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
throw new UnsupportedOperationException();
}
@Override
protected Object load(String entityName, Object identifier) {
return null;
}
public boolean isDefaultReadOnly() {
return false;
}