continued work on replacing LoadPlan with SQL AST approach - cleanup;

change expected type of entity identifier values from Serializable to Object
This commit is contained in:
Steve Ebersole 2019-11-07 06:38:40 -06:00
parent e522cbe542
commit 5b3c6c4884
221 changed files with 1299 additions and 1455 deletions

View File

@ -6,7 +6,6 @@
*/
package org.hibernate;
import java.io.Serializable;
import java.util.Optional;
import org.hibernate.graph.GraphSemantic;
@ -55,7 +54,7 @@ public interface IdentifierLoadAccess<T> {
*
* @return the persistent instance or proxy
*/
T getReference(Serializable id);
T getReference(Object id);
/**
* Return the persistent instance with the given identifier, or null if there is no such persistent instance.
@ -66,7 +65,7 @@ public interface IdentifierLoadAccess<T> {
*
* @return The persistent instance or {@code null}
*/
T load(Serializable id);
T load(Object id);
/**
* Same semantic as {@link #load} except that here {@link Optional} is returned to
@ -76,5 +75,5 @@ public interface IdentifierLoadAccess<T> {
*
* @return The persistent instance, if one, wrapped in Optional
*/
Optional<T> loadOptional(Serializable id);
Optional<T> loadOptional(Object id);
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate;
import java.io.Serializable;
import java.util.List;
import org.hibernate.graph.GraphSemantic;
@ -107,12 +106,12 @@ public interface MultiIdentifierLoadAccess<T> {
* and {@link #enableReturnOfDeletedEntities} for options which effect
* the size and "shape" of the return list.
*
* @param ids The ids to load
* @param <K> The identifier type
*
* @param ids The ids to load
* @return The persistent entities.
*/
<K extends Serializable> List<T> multiLoad(K... ids);
<K> List<T> multiLoad(K... ids);
/**
* Perform a load of multiple entities by identifiers. See {@link #enableOrderedReturn}
@ -124,5 +123,5 @@ public interface MultiIdentifierLoadAccess<T> {
*
* @return The persistent entities.
*/
<K extends Serializable> List<T> multiLoad(List<K> ids);
<K> List<T> multiLoad(List<K> ids);
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate;
import java.io.Serializable;
import java.util.Optional;
/**

View File

@ -18,17 +18,16 @@ import org.hibernate.pretty.MessageHelper;
* @author Gavin King
*/
public class NonUniqueObjectException extends HibernateException {
private final Serializable identifier;
private final Object identifier;
private final String entityName;
/**
* Constructs a NonUniqueObjectException using the given information.
*
* @param message A message explaining the exception condition
* @param message A message explaining the exception condition
* @param entityId The identifier of the entity
* @param entityName The name of the entity
*/
public NonUniqueObjectException(String message, Serializable entityId, String entityName) {
public NonUniqueObjectException(String message, Object entityId, String entityName) {
super( message );
this.entityName = entityName;
this.identifier = entityId;
@ -36,11 +35,10 @@ public class NonUniqueObjectException extends HibernateException {
/**
* Constructs a NonUniqueObjectException using the given information, using a standard message.
*
* @param entityId The identifier of the entity
* @param entityId The identifier of the entity
* @param entityName The name of the entity
*/
public NonUniqueObjectException(Serializable entityId, String entityName) {
public NonUniqueObjectException(Object entityId, String entityName) {
this(
"A different object with the same identifier value was already associated with the session",
entityId,
@ -52,7 +50,7 @@ public class NonUniqueObjectException extends HibernateException {
return entityName;
}
public Serializable getIdentifier() {
public Object getIdentifier() {
return identifier;
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate;
import java.io.Serializable;
/**
* Thrown when the user tries to do something illegal with a deleted object.
*
@ -16,12 +14,11 @@ import java.io.Serializable;
public class ObjectDeletedException extends UnresolvableObjectException {
/**
* Constructs an ObjectDeletedException using the given information.
*
* @param message A message explaining the exception condition
* @param message A message explaining the exception condition
* @param identifier The identifier of the entity
* @param entityName The name of the entity
*/
public ObjectDeletedException(String message, Serializable identifier, String entityName) {
public ObjectDeletedException(String message, Object identifier, String entityName) {
super( message, identifier, entityName );
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate;
import java.io.Serializable;
/**
* Thrown when <tt>Session.load()</tt> fails to select a row with
* the given primary key (identifier value). This exception might not
@ -24,11 +22,14 @@ import java.io.Serializable;
public class ObjectNotFoundException extends UnresolvableObjectException {
/**
* Constructs a ObjectNotFoundException using the given information.
*
* @param identifier The identifier of the entity
* @param identifier The identifier of the entity
* @param entityName The name of the entity
*/
public ObjectNotFoundException(Serializable identifier, String entityName) {
public ObjectNotFoundException(Object identifier, String entityName) {
super( identifier, entityName );
}
public ObjectNotFoundException(String entityName, Object identifier) {
this( identifier, entityName );
}
}

View File

@ -20,7 +20,6 @@ import javax.persistence.criteria.CriteriaUpdate;
import org.hibernate.graph.RootGraph;
import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.Work;
import org.hibernate.jpa.HibernateEntityManager;
import org.hibernate.stat.SessionStatistics;
/**
@ -235,7 +234,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* To override this session's read-only/modifiable setting for entities
* and proxies loaded by a Query:
* @see Query#setReadOnly(boolean)
* @see org.hibernate.query.Query#setReadOnly(boolean)
*
* @param readOnly true, the default for loaded entities/proxies is read-only;
* false, the default for loaded entities/proxies is modifiable
@ -252,7 +251,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
* @throws TransientObjectException if the instance is transient or associated with
* a different session
*/
Serializable getIdentifier(Object object);
Object getIdentifier(Object object);
/**
* Check if this entity is associated with this Session. This form caters to
@ -281,7 +280,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
* 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, Serializable, LockOptions)}
* 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
@ -289,9 +288,9 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return the persistent instance or proxy
*
* @see #load(Class, Serializable, LockOptions)
* @see #load(Class, Object, LockOptions)
*/
<T> T load(Class<T> theClass, Serializable id, LockMode lockMode);
<T> T load(Class<T> theClass, Object id, LockMode lockMode);
/**
* Return the persistent instance of the given entity class with the given identifier,
@ -302,13 +301,13 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
* @param lockOptions contains the lock level
* @return the persistent instance or proxy
*/
<T> T load(Class<T> theClass, Serializable id, LockOptions lockOptions);
<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, Serializable, LockOptions)}
* Convenient form of {@link #load(String, Object, LockOptions)}
*
* @param entityName a persistent class
* @param id a valid identifier of an existing persistent instance of the class
@ -316,9 +315,9 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return the persistent instance or proxy
*
* @see #load(String, Serializable, LockOptions)
* @see #load(String, Object, LockOptions)
*/
Object load(String entityName, Serializable id, LockMode lockMode);
Object load(String entityName, Object id, LockMode lockMode);
/**
* Return the persistent instance of the given entity class with the given identifier,
@ -330,7 +329,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return the persistent instance or proxy
*/
Object load(String entityName, Serializable id, LockOptions lockOptions);
Object load(String entityName, Object id, LockOptions lockOptions);
/**
* Return the persistent instance of the given entity class with the given identifier,
@ -346,7 +345,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return the persistent instance or proxy
*/
<T> T load(Class<T> theClass, Serializable id);
<T> T load(Class<T> theClass, Object id);
/**
* Return the persistent instance of the given entity class with the given identifier,
@ -362,16 +361,13 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return the persistent instance or proxy
*/
Object load(String entityName, Serializable id);
Object load(String entityName, Object id);
/**
* Read the persistent state associated with the given identifier into the given transient
* instance.
*
* @param object an "empty" instance of the persistent class
* @param id a valid identifier of an existing persistent instance of the class
*/
void load(Object object, Serializable id);
void load(Object object, Object id);
/**
* Persist the state of the given detached instance, reusing the current
@ -404,7 +400,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return the generated identifier
*/
Serializable save(Object object);
Object save(Object object);
/**
* Persist the given transient instance, first assigning a generated identifier. (Or
@ -417,7 +413,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return the generated identifier
*/
Serializable save(String entityName, Object object);
Object save(String entityName, Object object);
/**
* Either {@link #save(Object)} or {@link #update(Object)} the given
@ -693,7 +689,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return a persistent instance or null
*/
<T> T get(Class<T> entityType, Serializable id);
<T> T get(Class<T> entityType, Object id);
/**
* Return the persistent instance of the given entity class with the given identifier,
@ -701,7 +697,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
* with the session, return that instance. This method never returns an uninitialized instance.)
* Obtain the specified lock mode if the instance exists.
* <p/>
* Convenient form of {@link #get(Class, Serializable, LockOptions)}
* Convenient form of {@link #get(Class, Object, LockOptions)}
*
* @param entityType The entity type
* @param id an identifier
@ -709,9 +705,9 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return a persistent instance or null
*
* @see #get(Class, Serializable, LockOptions)
* @see #get(Class, Object, LockOptions)
*/
<T> T get(Class<T> entityType, Serializable id, LockMode lockMode);
<T> T get(Class<T> entityType, Object id, LockMode lockMode);
/**
* Return the persistent instance of the given entity class with the given identifier,
@ -725,7 +721,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return a persistent instance or null
*/
<T> T get(Class<T> entityType, Serializable id, LockOptions lockOptions);
<T> T get(Class<T> entityType, Object id, LockOptions lockOptions);
/**
* Return the persistent instance of the given named entity with the given identifier,
@ -737,7 +733,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return a persistent instance or null
*/
Object get(String entityName, Serializable id);
Object get(String entityName, Object id);
/**
* Return the persistent instance of the given entity class with the given identifier,
@ -745,7 +741,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
* with the session, return that instance. This method never returns an uninitialized instance.)
* Obtain the specified lock mode if the instance exists.
* <p/>
* Convenient form of {@link #get(String, Serializable, LockOptions)}
* Convenient form of {@link #get(String, Object, LockOptions)}
*
* @param entityName the entity name
* @param id an identifier
@ -753,7 +749,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return a persistent instance or null
*
* @see #get(String, Serializable, LockOptions)
* @see #get(String, Object, LockOptions)
*/
Object get(String entityName, Serializable id, LockMode lockMode);
@ -769,7 +765,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* @return a persistent instance or null
*/
Object get(String entityName, Serializable id, LockOptions lockOptions);
Object get(String entityName, Object id, LockOptions lockOptions);
/**
* Return the entity name for a persistent entity.
@ -936,7 +932,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
*
* To override this session's read-only/modifiable setting for entities
* and proxies loaded by a Query:
* @see Query#setReadOnly(boolean)
* @see org.hibernate.query.Query#setReadOnly(boolean)
*
* @param entityOrProxy an entity or HibernateProxy
* @param readOnly {@code true} if the entity or proxy should be made read-only; {@code false} if the entity or

View File

@ -6,8 +6,6 @@
*/
package org.hibernate;
import java.io.Serializable;
import org.hibernate.pretty.MessageHelper;
/**
@ -18,15 +16,14 @@ import org.hibernate.pretty.MessageHelper;
*/
public class StaleObjectStateException extends StaleStateException {
private final String entityName;
private final Serializable identifier;
private final Object identifier;
/**
* Constructs a StaleObjectStateException using the supplied information.
*
* @param entityName The name of the entity
* @param entityName The name of the entity
* @param identifier The identifier of the entity
*/
public StaleObjectStateException(String entityName, Serializable identifier) {
public StaleObjectStateException(String entityName, Object identifier) {
super( "Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)" );
this.entityName = entityName;
this.identifier = identifier;
@ -36,7 +33,7 @@ public class StaleObjectStateException extends StaleStateException {
return entityName;
}
public Serializable getIdentifier() {
public Object getIdentifier() {
return identifier;
}

View File

@ -7,7 +7,6 @@
package org.hibernate;
import java.io.Closeable;
import java.io.Serializable;
import java.sql.Connection;
import org.hibernate.annotations.Remove;
@ -42,7 +41,7 @@ public interface StatelessSession extends SharedSessionContract, AutoCloseable,
*
* @return The identifier of the inserted entity
*/
Serializable insert(Object entity);
Object insert(Object entity);
/**
* Insert a row.
@ -52,7 +51,7 @@ public interface StatelessSession extends SharedSessionContract, AutoCloseable,
*
* @return the identifier of the instance
*/
Serializable insert(String entityName, Object entity);
Object insert(String entityName, Object entity);
/**
* Update a row.
@ -92,7 +91,7 @@ public interface StatelessSession extends SharedSessionContract, AutoCloseable,
*
* @return a detached entity instance
*/
Object get(String entityName, Serializable id);
Object get(String entityName, Object id);
/**
* Retrieve a row.
@ -102,7 +101,7 @@ public interface StatelessSession extends SharedSessionContract, AutoCloseable,
*
* @return a detached entity instance
*/
Object get(Class entityClass, Serializable id);
Object get(Class entityClass, Object id);
/**
* Retrieve a row, obtaining the specified lock mode.
@ -113,7 +112,7 @@ public interface StatelessSession extends SharedSessionContract, AutoCloseable,
*
* @return a detached entity instance
*/
Object get(String entityName, Serializable id, LockMode lockMode);
Object get(String entityName, Object id, LockMode lockMode);
/**
* Retrieve a row, obtaining the specified lock mode.
@ -124,7 +123,7 @@ public interface StatelessSession extends SharedSessionContract, AutoCloseable,
*
* @return a detached entity instance
*/
Object get(Class entityClass, Serializable id, LockMode lockMode);
Object get(Class entityClass, Object id, LockMode lockMode);
/**
* Refresh the entity instance state from the database.

View File

@ -17,20 +17,19 @@ import org.hibernate.pretty.MessageHelper;
* @author Gavin King
*/
public class UnresolvableObjectException extends HibernateException {
private final Serializable identifier;
private final Object identifier;
private final String entityName;
/**
* Constructs an UnresolvableObjectException using the specified information.
*
* @param identifier The identifier of the entity which could not be resolved
* @param identifier The identifier of the entity which could not be resolved
* @param entityName The name of the entity which could not be resolved
*/
public UnresolvableObjectException(Serializable identifier, String entityName) {
public UnresolvableObjectException(Object identifier, String entityName) {
this( "No row with the given identifier exists", identifier, entityName );
}
protected UnresolvableObjectException(String message, Serializable identifier, String clazz) {
protected UnresolvableObjectException(String message, Object identifier, String clazz) {
super( message );
this.identifier = identifier;
this.entityName = clazz;
@ -45,14 +44,14 @@ public class UnresolvableObjectException extends HibernateException {
*
* @throws UnresolvableObjectException Thrown if entity is null
*/
public static void throwIfNull(Object entity, Serializable identifier, String entityName)
public static void throwIfNull(Object entity, Object identifier, String entityName)
throws UnresolvableObjectException {
if ( entity == null ) {
throw new UnresolvableObjectException( identifier, entityName );
}
}
public Serializable getIdentifier() {
public Object getIdentifier() {
return identifier;
}

View File

@ -15,17 +15,16 @@ import java.io.Serializable;
* @author Gavin King
*/
public class WrongClassException extends HibernateException {
private final Serializable identifier;
private final Object identifier;
private final String entityName;
/**
* Constructs a WrongClassException using the supplied information.
*
* @param message A message explaining the exception condition
* @param message A message explaining the exception condition
* @param identifier The identifier of the entity
* @param entityName The entity-type requested
*/
public WrongClassException(String message, Serializable identifier, String entityName) {
public WrongClassException(String message, Object identifier, String entityName) {
super(
String.format(
"Object [id=%s] was not of the specified subclass [%s] : %s",
@ -42,7 +41,7 @@ public class WrongClassException extends HibernateException {
return entityName;
}
public Serializable getIdentifier() {
public Object getIdentifier() {
return identifier;
}
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.LockMode;
import org.hibernate.engine.internal.ForeignKeys;
import org.hibernate.engine.internal.NonNullableTransientDependencies;
@ -34,17 +32,16 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
/**
* Constructs an AbstractEntityInsertAction object.
*
* @param id - the entity ID
* @param id - the entity ID
* @param state - the entity state
* @param instance - the entity
* @param isVersionIncrementDisabled - true, if version increment should
* be disabled; false, otherwise
* be disabled; false, otherwise
* @param persister - the entity persister
* @param session - the session
*/
protected AbstractEntityInsertAction(
Serializable id,
Object id,
Object[] state,
Object instance,
boolean isVersionIncrementDisabled,
@ -180,7 +177,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
*
* @param generatedId The generated entity identifier
*/
public void handleNaturalIdPostSaveNotifications(Serializable generatedId) {
public void handleNaturalIdPostSaveNotifications(Object generatedId) {
final PersistenceContext.NaturalIdHelper naturalIdHelper = getSession().getPersistenceContextInternal().getNaturalIdHelper();
if ( isEarlyInsert() ) {
// with early insert, we still need to add a local (transactional) natural id cross-reference

View File

@ -34,13 +34,13 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
private transient SharedSessionContractImplementor session;
private final PersistentCollection collection;
private final Serializable key;
private final Object key;
private final String collectionRole;
protected CollectionAction(
final CollectionPersister persister,
final PersistentCollection collection,
final Serializable key,
final Object key,
final SharedSessionContractImplementor session) {
this.persister = persister;
this.session = session;
@ -110,8 +110,8 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
return persister;
}
protected final Serializable getKey() {
Serializable finalKey = key;
protected final Object getKey() {
Object finalKey = key;
if ( key instanceof DelayedPostInsertIdentifier ) {
// need to look it up from the persistence-context
finalKey = session.getPersistenceContextInternal().getEntry( collection.getOwner() ).getId();
@ -161,11 +161,11 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
}
private static class CacheCleanupProcess implements AfterTransactionCompletionProcess {
private final Serializable key;
private final Object key;
private final CollectionPersister persister;
private final SoftLock lock;
private CacheCleanupProcess(Serializable key, CollectionPersister persister, SoftLock lock) {
private CacheCleanupProcess(Object key, CollectionPersister persister, SoftLock lock) {
this.key = key;
this.persister = persister;
this.lock = lock;

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
@ -27,8 +25,7 @@ public final class CollectionRecreateAction extends CollectionAction {
/**
* Constructs a CollectionRecreateAction
*
* @param collection The collection being recreated
* @param collection The collection being recreated
* @param persister The collection persister
* @param id The collection key
* @param session The session
@ -36,7 +33,7 @@ public final class CollectionRecreateAction extends CollectionAction {
public CollectionRecreateAction(
final PersistentCollection collection,
final CollectionPersister persister,
final Serializable id,
final Object id,
final SharedSessionContractImplementor session) {
super( persister, collection, id, session );
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.collection.spi.PersistentCollection;
@ -44,7 +42,7 @@ public final class CollectionRemoveAction extends CollectionAction {
public CollectionRemoveAction(
final PersistentCollection collection,
final CollectionPersister persister,
final Serializable id,
final Object id,
final boolean emptySnapshot,
final SharedSessionContractImplementor session) {
super( persister, collection, id, session );
@ -74,7 +72,7 @@ public final class CollectionRemoveAction extends CollectionAction {
public CollectionRemoveAction(
final Object affectedOwner,
final CollectionPersister persister,
final Serializable id,
final Object id,
final boolean emptySnapshot,
final SharedSessionContractImplementor session) {
super( persister, null, id, session );

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.collection.spi.PersistentCollection;
@ -30,8 +28,7 @@ public final class CollectionUpdateAction extends CollectionAction {
/**
* Constructs a CollectionUpdateAction
*
* @param collection The collection to update
* @param collection The collection to update
* @param persister The collection persister
* @param id The collection key
* @param emptySnapshot Indicates if the snapshot is empty
@ -40,7 +37,7 @@ public final class CollectionUpdateAction extends CollectionAction {
public CollectionUpdateAction(
final PersistentCollection collection,
final CollectionPersister persister,
final Serializable id,
final Object id,
final boolean emptySnapshot,
final SharedSessionContractImplementor session) {
super( persister, collection, id, session );
@ -49,7 +46,7 @@ public final class CollectionUpdateAction extends CollectionAction {
@Override
public void execute() throws HibernateException {
final Serializable id = getKey();
final Object id = getKey();
final SharedSessionContractImplementor session = getSession();
final CollectionPersister persister = getPersister();
final PersistentCollection collection = getCollection();

View File

@ -35,7 +35,7 @@ public abstract class EntityAction
private static final Logger LOG = Logger.getLogger(EntityAction.class);
private final String entityName;
private final Serializable id;
private final Object id;
private transient Object instance;
private transient SharedSessionContractImplementor session;
@ -51,7 +51,7 @@ public abstract class EntityAction
* @param instance The entity instance
* @param persister The entity persister
*/
protected EntityAction(SharedSessionContractImplementor session, Serializable id, Object instance, EntityPersister persister) {
protected EntityAction(SharedSessionContractImplementor session, Object id, Object instance, EntityPersister persister) {
this.entityName = persister.getEntityName();
this.id = id;
this.instance = instance;
@ -99,10 +99,10 @@ public abstract class EntityAction
*
* @return The entity id
*/
public final Serializable getId() {
public final Object getId() {
if ( id instanceof DelayedPostInsertIdentifier ) {
final EntityEntry entry = session.getPersistenceContextInternal().getEntry( instance );
final Serializable eeId = entry == null ? null : entry.getId();
final Object eeId = entry == null ? null : entry.getId();
return eeId instanceof DelayedPostInsertIdentifier ? null : eeId;
}
return id;

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.cache.spi.access.EntityDataAccess;
@ -39,8 +37,7 @@ public class EntityDeleteAction extends EntityAction {
/**
* Constructs an EntityDeleteAction.
*
* @param id The entity identifier
* @param id The entity identifier
* @param state The current (extracted) entity state
* @param version The current entity version
* @param instance The entity instance
@ -49,7 +46,7 @@ public class EntityDeleteAction extends EntityAction {
* @param session The session
*/
public EntityDeleteAction(
final Serializable id,
final Object id,
final Object[] state,
final Object version,
final Object instance,
@ -71,7 +68,7 @@ public class EntityDeleteAction extends EntityAction {
@Override
public void execute() throws HibernateException {
final Serializable id = getId();
final Object id = getId();
final EntityPersister persister = getPersister();
final SharedSessionContractImplementor session = getSession();
final Object instance = getInstance();

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.EntityKey;
@ -34,7 +32,7 @@ public final class EntityIdentityInsertAction extends AbstractEntityInsertAction
private final boolean isDelayed;
private final EntityKey delayedEntityKey;
private EntityKey entityKey;
private Serializable generatedId;
private Object generatedId;
/**
* Constructs an EntityIdentityInsertAction
@ -176,7 +174,7 @@ public final class EntityIdentityInsertAction extends AbstractEntityInsertAction
eventSource()
);
for ( PostInsertEventListener listener : listenerGroup.listeners() ) {
if ( PostCommitInsertEventListener.class.isInstance( listener ) ) {
if ( listener instanceof PostCommitInsertEventListener ) {
if ( success ) {
listener.onPostInsert( event );
}
@ -210,7 +208,7 @@ public final class EntityIdentityInsertAction extends AbstractEntityInsertAction
*
* @return The generated identifier
*/
public final Serializable getGeneratedId() {
public final Object getGeneratedId() {
return generatedId;
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.cache.spi.access.EntityDataAccess;
@ -41,8 +39,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
/**
* Constructs an EntityInsertAction.
*
* @param id The entity identifier
* @param id The entity identifier
* @param state The current (extracted) entity state
* @param instance The entity instance
* @param version The current entity version value
@ -51,7 +48,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
* @param session The session
*/
public EntityInsertAction(
Serializable id,
Object id,
Object[] state,
Object instance,
Object version,
@ -79,7 +76,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
final EntityPersister persister = getPersister();
final SharedSessionContractImplementor session = getSession();
final Object instance = getInstance();
final Serializable id = getId();
final Object id = getId();
final boolean veto = preInsert();

View File

@ -51,8 +51,7 @@ public final class EntityUpdateAction extends EntityAction {
/**
* Constructs an EntityUpdateAction
*
* @param id The entity identifier
* @param id The entity identifier
* @param state The current (extracted) entity state
* @param dirtyProperties The indexes (in reference to state) properties with dirty state
* @param hasDirtyCollection Were any collections dirty?
@ -65,7 +64,7 @@ public final class EntityUpdateAction extends EntityAction {
* @param session The session
*/
public EntityUpdateAction(
final Serializable id,
final Object id,
final Object[] state,
final int[] dirtyProperties,
final boolean hasDirtyCollection,
@ -85,7 +84,7 @@ public final class EntityUpdateAction extends EntityAction {
this.hasDirtyCollection = hasDirtyCollection;
this.rowId = rowId;
this.previousNaturalIdValues = determinePreviousNaturalIdValues( persister, previousState, session, id );
this.previousNaturalIdValues = determinePreviousNaturalIdValues( persister, id, previousState, session );
session.getPersistenceContextInternal().getNaturalIdHelper().manageLocalNaturalIdCrossReference(
persister,
id,
@ -97,9 +96,8 @@ public final class EntityUpdateAction extends EntityAction {
private Object[] determinePreviousNaturalIdValues(
EntityPersister persister,
Object[] previousState,
SharedSessionContractImplementor session,
Serializable id) {
Object id, Object[] previousState,
SharedSessionContractImplementor session) {
if ( ! persister.hasNaturalIdentifier() ) {
return null;
}
@ -114,7 +112,7 @@ public final class EntityUpdateAction extends EntityAction {
@Override
public void execute() throws HibernateException {
final Serializable id = getId();
final Object id = getId();
final EntityPersister persister = getPersister();
final SharedSessionContractImplementor session = getSession();
final Object instance = getInstance();

View File

@ -6,14 +6,13 @@
*/
package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.persister.entity.EntityPersister;
public final class OrphanRemovalAction extends EntityDeleteAction {
public OrphanRemovalAction(Serializable id, Object[] state, Object version, Object instance,
public OrphanRemovalAction(
Object id, Object[] state, Object version, Object instance,
EntityPersister persister, boolean isCascadeDeleteEnabled, SessionImplementor session) {
super( id, state, version, instance, persister, isCascadeDeleteEnabled, session );
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.collection.internal.AbstractPersistentCollection;
import org.hibernate.collection.spi.PersistentCollection;
@ -26,8 +24,7 @@ public final class QueuedOperationCollectionAction extends CollectionAction {
/**
* Constructs a CollectionUpdateAction
*
* @param collection The collection to update
* @param collection The collection to update
* @param persister The collection persister
* @param id The collection key
* @param session The session
@ -35,7 +32,7 @@ public final class QueuedOperationCollectionAction extends CollectionAction {
public QueuedOperationCollectionAction(
final PersistentCollection collection,
final CollectionPersister persister,
final Serializable id,
final Object id,
final SharedSessionContractImplementor session) {
super( persister, collection, id, session );
}

View File

@ -9,7 +9,6 @@ package org.hibernate.action.internal;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Map;
@ -129,7 +128,7 @@ public class UnresolvedEntityInsertActions {
for ( Map.Entry<Object,Set<AbstractEntityInsertAction>> entry : dependentActionsByTransientEntity.entrySet() ) {
final Object transientEntity = entry.getKey();
final String transientEntityName = session.guessEntityName( transientEntity );
final Serializable transientEntityId = session.getFactory().getMetamodel().entityPersister( transientEntityName ).getIdentifier( transientEntity, session );
final Object transientEntityId = session.getFactory().getMetamodel().entityPersister( transientEntityName ).getIdentifier( transientEntity, session );
final String transientEntityString = MessageHelper.infoString( transientEntityName, transientEntityId );
final Set<String> dependentEntityStrings = new TreeSet<>();
final Set<String> nonNullableTransientPropertyPaths = new TreeSet<>();

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.boot.internal;
import java.io.Serializable;
import org.hibernate.ObjectNotFoundException;
import org.hibernate.proxy.EntityNotFoundDelegate;
@ -24,7 +22,7 @@ public class StandardEntityNotFoundDelegate implements EntityNotFoundDelegate {
public static final StandardEntityNotFoundDelegate INSTANCE = new StandardEntityNotFoundDelegate();
@Override
public void handleEntityNotFound(String entityName, Serializable id) {
throw new ObjectNotFoundException( id, entityName );
public void handleEntityNotFound(String entityName, Object id) {
throw new ObjectNotFoundException( entityName, id );
}
}

View File

@ -7,7 +7,6 @@
package org.hibernate.bytecode.enhance.spi.interceptor;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@ -79,7 +78,7 @@ public class LazyAttributeLoadingInterceptor extends AbstractLazyLoadInterceptor
final EntityPersister persister = session.getFactory().getMetamodel().entityPersister( getEntityName() );
if ( isTemporarySession ) {
final Serializable id = persister.getIdentifier( target, null );
final Object id = persister.getIdentifier( target, null );
// Add an entry for this entity in the PC of the temp Session
// NOTE : a few arguments that would be nice to pass along here...

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.bytecode.internal.none;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Set;
@ -32,7 +31,7 @@ final class DisallowedProxyFactory implements ProxyFactory {
}
@Override
public HibernateProxy getProxy(Serializable id, SharedSessionContractImplementor session) throws HibernateException {
public HibernateProxy getProxy(Object id, SharedSessionContractImplementor session) throws HibernateException {
throw new HibernateException( "Generation of HibernateProxy instances at runtime is not allowed when the configured BytecodeProvider is 'none'; your model requires a more advanced BytecodeProvider to be enabled." );
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.cache.internal;
import java.io.Serializable;
import java.util.Set;
import org.hibernate.HibernateException;
@ -123,14 +122,14 @@ public class CollectionCacheInvalidator
if ( !collectionPersister.isManyToMany() &&
mappedBy != null && !mappedBy.isEmpty() ) {
int i = entityMetamodel.getPropertyIndex( mappedBy );
Serializable oldId = null;
Object oldId = null;
if ( oldState != null ) {
// in case of updating an entity we perhaps have to decache 2 entity collections, this is the
// old one
oldId = getIdentifier( session, oldState[i] );
}
Object ref = persister.getPropertyValue( entity, i );
Serializable id = getIdentifier( session, ref );
Object id = getIdentifier( session, ref );
// only evict if the related entity has changed
if ( ( id != null && !id.equals( oldId ) ) || ( oldId != null && !oldId.equals( id ) ) ) {
@ -163,8 +162,8 @@ public class CollectionCacheInvalidator
}
}
private Serializable getIdentifier(EventSource session, Object obj) {
Serializable id = null;
private Object getIdentifier(EventSource session, Object obj) {
Object id = null;
if ( obj != null ) {
id = session.getContextEntityIdentifier( obj );
if ( id == null ) {
@ -174,7 +173,7 @@ public class CollectionCacheInvalidator
return id;
}
private void evict(Serializable id, CollectionPersister collectionPersister, EventSource session) {
private void evict(Object id, CollectionPersister collectionPersister, EventSource session) {
if ( LOG.isDebugEnabled() ) {
LOG.debug( "Evict CollectionRegion " + collectionPersister.getRole() + " for id " + id );
}
@ -192,7 +191,7 @@ public class CollectionCacheInvalidator
protected CollectionEvictCacheAction(
CollectionPersister persister,
PersistentCollection collection,
Serializable key,
Object key,
SharedSessionContractImplementor session) {
super( persister, collection, key, session );
}

View File

@ -28,7 +28,7 @@ import org.hibernate.type.Type;
* @author Steve Ebersole
*/
public class NaturalIdCacheKey implements Serializable {
private final Serializable[] naturalIdValues;
private final Object[] naturalIdValues;
private final String entityName;
private final String tenantId;
private final int hashCode;
@ -114,7 +114,7 @@ public class NaturalIdCacheKey implements Serializable {
}
@SuppressWarnings( {"UnusedDeclaration"})
public Serializable[] getNaturalIdValues() {
public Object[] getNaturalIdValues() {
return naturalIdValues;
}

View File

@ -18,7 +18,7 @@ import org.hibernate.persister.collection.CollectionPersister;
* @author Gavin King
*/
public class CollectionCacheEntry implements Serializable {
private final Serializable state;
private final Object state;
/**
* Constructs a CollectionCacheEntry

View File

@ -123,7 +123,7 @@ public class StandardCacheEntryImpl implements CacheEntry {
*/
public Object[] assemble(
final Object instance,
final Serializable id,
final Object id,
final EntityPersister persister,
final Interceptor interceptor,
final EventSource session) throws HibernateException {

View File

@ -67,7 +67,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
private int cachedSize = -1;
private String role;
private Serializable key;
private Object key;
// collections detect changes made via their public interface and mark
// themselves as dirty as a performance optimization
private boolean dirty;
@ -102,7 +102,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
}
@Override
public final Serializable getKey() {
public final Object getKey() {
return key;
}
@ -521,7 +521,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
}
@Override
public void setSnapshot(Serializable key, String role, Serializable snapshot) {
public void setSnapshot(Object key, String role, Serializable snapshot) {
this.key = key;
this.role = role;
this.storedSnapshot = snapshot;
@ -711,7 +711,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
// change it). Don't access the CollectionEntry in this.session because that could result
// in multi-threaded access to this.session.
final String roleCurrent = role;
final Serializable keyCurrent = key;
final Object keyCurrent = key;
final StringBuilder sb = new StringBuilder( "Collection : " );
if ( roleCurrent != null ) {
@ -1261,7 +1261,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
currentSaving.add( current );
}
else {
final Serializable currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved(
final Object currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved(
entityName,
current,
session
@ -1274,7 +1274,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
// iterate over the *old* list
for ( Object old : oldElements ) {
if ( !currentSaving.contains( old ) ) {
final Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session );
final Object oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session );
if ( !currentIds.contains( useIdDirect ? oldId : new TypedValue( idType, oldId ) ) ) {
res.add( old );
}
@ -1311,10 +1311,10 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers
final EntityPersister entityPersister = session.getFactory().getEntityPersister( entityName );
final Type idType = entityPersister.getIdentifierType();
final Serializable idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, entityInstance, session );
final Object idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, entityInstance, session );
final Iterator itr = list.iterator();
while ( itr.hasNext() ) {
final Serializable idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, itr.next(), session );
final Object idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, itr.next(), session );
if ( idType.isEqual( idOfCurrent, idOfOld, session.getFactory() ) ) {
itr.remove();
break;

View File

@ -251,7 +251,7 @@ public class PersistentArrayHolder extends AbstractPersistentCollection {
}
@Override
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner)
throws HibernateException {
final Serializable[] cached = (Serializable[]) disassembled;
array = Array.newInstance( persister.getElementClass(), cached.length );
@ -262,9 +262,9 @@ public class PersistentArrayHolder extends AbstractPersistentCollection {
}
@Override
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
public Object disassemble(CollectionPersister persister) throws HibernateException {
final int length = Array.getLength( array );
final Serializable[] result = new Serializable[length];
final Object[] result = new Object[length];
for ( int i=0; i<length; i++ ) {
result[i] = persister.getElementType().disassemble( Array.get( array,i ), getSession(), null );
}

View File

@ -261,10 +261,9 @@ public class PersistentBag extends AbstractPersistentCollection implements List
}
@Override
public Serializable disassemble(CollectionPersister persister)
throws HibernateException {
public Object disassemble(CollectionPersister persister) {
final int length = bag.size();
final Serializable[] result = new Serializable[length];
final Object[] result = new Object[length];
for ( int i=0; i<length; i++ ) {
result[i] = persister.getElementType().disassemble( bag.get( i ), getSession(), null );
}
@ -273,7 +272,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
@Override
@SuppressWarnings("unchecked")
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner)
throws HibernateException {
final Serializable[] array = (Serializable[]) disassembled;
final int size = array.length;

View File

@ -106,7 +106,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
}
@Override
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner)
throws HibernateException {
final Serializable[] array = (Serializable[]) disassembled;
final int size = array.length;
@ -247,9 +247,8 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
}
@Override
public Serializable disassemble(CollectionPersister persister)
throws HibernateException {
final Serializable[] result = new Serializable[ values.size() * 2 ];
public Object disassemble(CollectionPersister persister) {
final Object[] result = new Object[ values.size() * 2 ];
int i = 0;
for ( int j=0; j< values.size(); j++ ) {
final Object value = values.get( j );
@ -429,7 +428,7 @@ public class PersistentIdentifierBag extends AbstractPersistentCollection implem
final Integer loc = i++;
if ( !identifiers.containsKey( loc ) ) {
//TODO: native ids
final Serializable id = persister.getIdentifierGenerator().generate( getSession(), entry );
final Object id = persister.getIdentifierGenerator().generate( getSession(), entry );
identifiers.put( loc, id );
}
}

View File

@ -437,7 +437,7 @@ public class PersistentList extends AbstractPersistentCollection implements List
@Override
@SuppressWarnings("unchecked")
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner)
throws HibernateException {
final Serializable[] array = (Serializable[]) disassembled;
final int size = array.length;
@ -448,10 +448,9 @@ public class PersistentList extends AbstractPersistentCollection implements List
}
@Override
@SuppressWarnings("unchecked")
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
public Object disassemble(CollectionPersister persister) throws HibernateException {
final int length = list.size();
final Serializable[] result = new Serializable[length];
final Object[] result = new Object[length];
for ( int i=0; i<length; i++ ) {
result[i] = persister.getElementType().disassemble( list.get( i ), getSession(), null );
}

View File

@ -497,7 +497,7 @@ public class PersistentMap extends AbstractPersistentCollection implements Map {
@Override
@SuppressWarnings("unchecked")
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner)
throws HibernateException {
final Serializable[] array = (Serializable[]) disassembled;
final int size = array.length;
@ -511,9 +511,8 @@ public class PersistentMap extends AbstractPersistentCollection implements Map {
}
@Override
@SuppressWarnings("unchecked")
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
final Serializable[] result = new Serializable[ map.size() * 2 ];
public Object disassemble(CollectionPersister persister) throws HibernateException {
final Object[] result = new Object[ map.size() * 2 ];
final Iterator itr = map.entrySet().iterator();
int i=0;
while ( itr.hasNext() ) {

View File

@ -146,7 +146,7 @@ public class PersistentSet extends AbstractPersistentCollection implements java.
@Override
@SuppressWarnings("unchecked")
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner)
throws HibernateException {
final Serializable[] array = (Serializable[]) disassembled;
final int size = array.length;
@ -388,9 +388,8 @@ public class PersistentSet extends AbstractPersistentCollection implements java.
}
@Override
@SuppressWarnings("unchecked")
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
final Serializable[] result = new Serializable[ set.size() ];
public Object disassemble(CollectionPersister persister) throws HibernateException {
final Object[] result = new Object[ set.size() ];
final Iterator itr = set.iterator();
int i=0;
while ( itr.hasNext() ) {

View File

@ -73,12 +73,11 @@ public interface PersistentCollection {
/**
* After flushing, re-init snapshot state.
*
* @param key The collection instance key (fk value).
* @param key The collection instance key (fk value).
* @param role The collection role
* @param snapshot The snapshot state
*/
void setSnapshot(Serializable key, String role, Serializable snapshot);
void setSnapshot(Object key, String role, Serializable snapshot);
/**
* After flushing, clear any "queued" additions, since the
@ -143,12 +142,11 @@ public interface PersistentCollection {
/**
* Read the state of the collection from a disassembled cached value
*
* @param persister The collection persister
* @param persister The collection persister
* @param disassembled The disassembled cached state
* @param owner The collection owner
*/
void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner);
void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner);
/**
* Iterate all collection entries, during update of the database
@ -260,7 +258,7 @@ public interface PersistentCollection {
*
* @return The disassembled state
*/
Serializable disassemble(CollectionPersister persister) ;
Object disassemble(CollectionPersister persister) ;
/**
* Do we need to completely recreate this collection when it changes?
@ -379,7 +377,7 @@ public interface PersistentCollection {
*
* @return the current collection key value
*/
Serializable getKey();
Object getKey();
/**
* Get the current role name

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.dialect;
import java.io.Serializable;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.Types;
@ -624,7 +623,7 @@ public class HSQLDialect extends Dialect {
}
@Override
public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session)
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session)
throws StaleObjectStateException, JDBCException {
if ( getLockMode().greaterThan( LockMode.READ ) ) {
LOG.hsqldbSupportsOnlyReadCommittedIsolation();

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import org.hibernate.StaleObjectStateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
@ -39,6 +37,6 @@ public interface LockingStrategy {
* the requested lock.
* @throws LockingStrategyException Indicates a failure in the lock attempt
*/
void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session)
void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session)
throws StaleObjectStateException, LockingStrategyException;
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.action.internal.EntityIncrementVersionProcess;
@ -44,7 +42,7 @@ public class OptimisticForceIncrementLockingStrategy implements LockingStrategy
}
@Override
public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
if ( !lockable.isVersioned() ) {
throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.OptimisticLockException;
@ -44,7 +42,7 @@ public class OptimisticLockingStrategy implements LockingStrategy {
}
@Override
public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
if ( !lockable.isVersioned() ) {
throw new OptimisticLockException( object, "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.engine.spi.EntityEntry;
@ -43,7 +41,7 @@ public class PessimisticForceIncrementLockingStrategy implements LockingStrategy
}
@Override
public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
if ( !lockable.isVersioned() ) {
throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -53,7 +52,7 @@ public class PessimisticReadSelectLockingStrategy extends AbstractSelectLockingS
}
@Override
public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
final String sql = determineSql( timeout );
final SessionFactoryImplementor factory = session.getFactory();
try {

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@ -69,7 +68,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy {
}
@Override
public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
if ( !lockable.isVersioned() ) {
throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -52,7 +51,7 @@ public class PessimisticWriteSelectLockingStrategy extends AbstractSelectLocking
}
@Override
public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
final String sql = determineSql( timeout );
final SessionFactoryImplementor factory = session.getFactory();
try {

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@ -68,7 +67,7 @@ public class PessimisticWriteUpdateLockingStrategy implements LockingStrategy {
}
@Override
public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
public void lock(Object id, Object version, Object object, int timeout, SharedSessionContractImplementor session) {
if ( !lockable.isVersioned() ) {
throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -48,7 +47,7 @@ public class SelectLockingStrategy extends AbstractSelectLockingStrategy {
@Override
public void lock(
Serializable id,
Object id,
Object version,
Object object,
int timeout,

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.dialect.lock;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@ -69,7 +68,7 @@ public class UpdateLockingStrategy implements LockingStrategy {
@Override
public void lock(
Serializable id,
Object id,
Object version,
Object object,
int timeout,

View File

@ -9,11 +9,9 @@ package org.hibernate.engine.internal;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.function.Supplier;
import org.hibernate.AssertionFailure;
import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.Session;
@ -43,7 +41,7 @@ import org.hibernate.pretty.MessageHelper;
* @author Sanne Grinovero <sanne@hibernate.org>
*/
public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
protected final Serializable id;
protected final Object id;
protected Object[] loadedState;
protected Object version;
protected final EntityPersister persister; // permanent but we only need the entityName state in a non transient way
@ -78,34 +76,11 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
*/
private transient int compressedState;
/**
* @deprecated the tenantId and entityMode parameters where removed: this constructor accepts but ignores them.
* Use the other constructor!
*/
@Deprecated
public AbstractEntityEntry(
final Status status,
final Object[] loadedState,
final Object rowId,
final Serializable id,
final Object version,
final LockMode lockMode,
final boolean existsInDatabase,
final EntityPersister persister,
final EntityMode entityMode,
final String tenantId,
final boolean disableVersionIncrement,
final PersistenceContext persistenceContext) {
this( status, loadedState, rowId, id, version, lockMode, existsInDatabase,
persister,disableVersionIncrement, persistenceContext
);
}
public AbstractEntityEntry(
final Status status,
final Object[] loadedState,
final Object rowId,
final Serializable id,
final Object id,
final Object version,
final LockMode lockMode,
final boolean existsInDatabase,
@ -196,7 +171,7 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
}
@Override
public Serializable getId() {
public Object getId() {
return id;
}

View File

@ -16,6 +16,7 @@ import org.hibernate.engine.spi.BatchFetchQueue;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.persister.entity.EntityPersister;
import org.jboss.logging.Logger;
@ -69,17 +70,20 @@ public class BatchFetchQueueHelper {
/**
* Remove the entity key with the specified {@code id} and {@code persister} from
* the batch loadable entities {@link BatchFetchQueue}.
*
* @param id - the ID for the entity to be removed
* @param persister - the entity persister
* @param session - the session
*/
public static void removeBatchLoadableEntityKey(
Serializable id,
Object id,
EntityPersister persister,
SharedSessionContractImplementor session) {
final EntityKey entityKey = session.generateEntityKey( id, persister );
final BatchFetchQueue batchFetchQueue = session.getPersistenceContextInternal().getBatchFetchQueue();
batchFetchQueue.removeBatchLoadableEntityKey( entityKey );
}
public static void removeBatchLoadableEntityKey(
Object id,
EntityMappingType entityMappingType,
SharedSessionContractImplementor session) {
removeBatchLoadableEntityKey( id, entityMappingType.getEntityPersister(), session );
}
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.engine.internal;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@ -323,7 +322,7 @@ public final class Cascade {
if ( valueEntry != null ) {
final String entityName = valueEntry.getPersister().getEntityName();
if ( LOG.isTraceEnabled() ) {
final Serializable id = valueEntry.getPersister().getIdentifier( loadedValue, eventSource );
final Object id = valueEntry.getPersister().getIdentifier( loadedValue, eventSource );
final String description = MessageHelper.infoString( entityName, id );
LOG.tracev( "Deleting orphaned entity instance: {0}", description );
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.engine.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.action.internal.DelayedPostInsertIdentifier;
@ -69,7 +67,7 @@ public final class Collections {
// do a check
final boolean hasOrphanDelete = loadedPersister != null && loadedPersister.hasOrphanDelete();
if ( hasOrphanDelete ) {
Serializable ownerId = loadedPersister.getOwnerEntityPersister().getIdentifier( coll.getOwner(), session );
Object ownerId = loadedPersister.getOwnerEntityPersister().getIdentifier( coll.getOwner(), session );
if ( ownerId == null ) {
// the owning entity may have been deleted and its identifier unset due to
// identifier-rollback; in which case, try to look up its identifier from

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.engine.internal;
import java.io.Serializable;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.TransientObjectException;
@ -328,7 +326,7 @@ public final class ForeignKeys {
*
* @throws TransientObjectException if the entity is transient (does not yet have an identifier)
*/
public static Serializable getEntityIdentifierIfNotUnsaved(
public static Object getEntityIdentifierIfNotUnsaved(
final String entityName,
final Object object,
final SharedSessionContractImplementor session) throws TransientObjectException {
@ -336,7 +334,7 @@ public final class ForeignKeys {
return null;
}
else {
Serializable id = session.getContextEntityIdentifier( object );
Object id = session.getContextEntityIdentifier( object );
if ( id == null ) {
// context-entity-identifier returns null explicitly if the entity
// is not associated with the persistence context; so make some

View File

@ -32,45 +32,11 @@ import org.hibernate.persister.entity.EntityPersister;
* @see org.hibernate.annotations.Immutable
*/
public final class ImmutableEntityEntry extends AbstractEntityEntry {
/**
* @deprecated the tenantId and entityMode parameters where removed: this constructor accepts but ignores them.
* Use the other constructor!
*/
@Deprecated
public ImmutableEntityEntry(
final Status status,
final Object[] loadedState,
final Object rowId,
final Serializable id,
final Object version,
final LockMode lockMode,
final boolean existsInDatabase,
final EntityPersister persister,
final EntityMode entityMode,
final String tenantId,
final boolean disableVersionIncrement,
final PersistenceContext persistenceContext) {
this(
status,
loadedState,
rowId,
id,
version,
lockMode,
existsInDatabase,
persister,
disableVersionIncrement,
// purposefully do not pass along the session/persistence-context : HHH-10251
null
);
}
public ImmutableEntityEntry(
final Status status,
final Object[] loadedState,
final Object rowId,
final Serializable id,
final Object id,
final Object version,
final LockMode lockMode,
final boolean existsInDatabase,

View File

@ -7,9 +7,6 @@
package org.hibernate.engine.internal;
import java.io.Serializable;
import java.util.Set;
import org.hibernate.LockMode;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.EntityEntryFactory;
@ -38,7 +35,7 @@ public class ImmutableEntityEntryFactory implements EntityEntryFactory {
Status status,
Object[] loadedState,
Object rowId,
Serializable id,
Object id,
Object version,
LockMode lockMode,
boolean existsInDatabase,

View File

@ -54,7 +54,7 @@ public final class MutableEntityEntry extends AbstractEntityEntry {
final Status status,
final Object[] loadedState,
final Object rowId,
final Serializable id,
final Object id,
final Object version,
final LockMode lockMode,
final boolean existsInDatabase,

View File

@ -7,9 +7,6 @@
package org.hibernate.engine.internal;
import java.io.Serializable;
import java.util.Set;
import org.hibernate.LockMode;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.EntityEntryFactory;
@ -38,7 +35,7 @@ public class MutableEntityEntryFactory implements EntityEntryFactory {
Status status,
Object[] loadedState,
Object rowId,
Serializable id,
Object id,
Object version,
LockMode lockMode,
boolean existsInDatabase,

View File

@ -70,7 +70,7 @@ public class NaturalIdXrefDelegate {
*
* @return {@code true} if a new entry was actually added; {@code false} otherwise.
*/
public boolean cacheNaturalIdCrossReference(EntityPersister persister, Serializable pk, Object[] naturalIdValues) {
public boolean cacheNaturalIdCrossReference(EntityPersister persister, Object pk, Object[] naturalIdValues) {
validateNaturalId( persister, naturalIdValues );
NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
@ -90,10 +90,10 @@ public class NaturalIdXrefDelegate {
* @param persister The persister representing the entity type.
* @param pk The primary key value
* @param naturalIdValues The natural id value(s)
*
*
* @return The cached values, if any. May be different from incoming values.
*/
public Object[] removeNaturalIdCrossReference(EntityPersister persister, Serializable pk, Object[] naturalIdValues) {
public Object[] removeNaturalIdCrossReference(EntityPersister persister, Object pk, Object[] naturalIdValues) {
persister = locatePersisterForKey( persister );
validateNaturalId( persister, naturalIdValues );
@ -130,10 +130,10 @@ public class NaturalIdXrefDelegate {
* @param persister The persister representing the entity type.
* @param pk The primary key value
* @param naturalIdValues The natural id value(s) to check
*
*
* @return {@code true} if the given naturalIdValues match the current cached values; {@code false} otherwise.
*/
public boolean sameAsCached(EntityPersister persister, Serializable pk, Object[] naturalIdValues) {
public boolean sameAsCached(EntityPersister persister, Object pk, Object[] naturalIdValues) {
final NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
return entityNaturalIdResolutionCache != null
&& entityNaturalIdResolutionCache.sameAsCached( pk, naturalIdValues );
@ -174,10 +174,10 @@ public class NaturalIdXrefDelegate {
*
* @param persister The persister representing the entity type.
* @param pk The entity primary key
*
* @return The corresponding cross-referenced natural id values, or {@code null} if none
*
* @return The corresponding cross-referenced natural id values, or {@code null} if none
*/
public Object[] findCachedNaturalId(EntityPersister persister, Serializable pk) {
public Object[] findCachedNaturalId(EntityPersister persister, Object pk) {
persister = locatePersisterForKey( persister );
final NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
if ( entityNaturalIdResolutionCache == null ) {
@ -204,13 +204,13 @@ public class NaturalIdXrefDelegate {
* {@link PersistenceContext.NaturalIdHelper#INVALID_NATURAL_ID_REFERENCE},
* or {@code null} if none
*/
public Serializable findCachedNaturalIdResolution(EntityPersister persister, Object[] naturalIdValues) {
public Object findCachedNaturalIdResolution(EntityPersister persister, Object[] naturalIdValues) {
persister = locatePersisterForKey( persister );
validateNaturalId( persister, naturalIdValues );
NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
Serializable pk;
Object pk;
final CachedNaturalId cachedNaturalId = new CachedNaturalId( persister, naturalIdValues );
if ( entityNaturalIdResolutionCache != null ) {
pk = entityNaturalIdResolutionCache.naturalIdToPkMap.get( cachedNaturalId );
@ -301,10 +301,10 @@ public class NaturalIdXrefDelegate {
*
* @see org.hibernate.NaturalIdLoadAccess#setSynchronizationEnabled
*/
public Collection<Serializable> getCachedPkResolutions(EntityPersister persister) {
public Collection<Object> getCachedPkResolutions(EntityPersister persister) {
persister = locatePersisterForKey( persister );
Collection<Serializable> pks = null;
Collection<Object> pks = null;
final NaturalIdResolutionCache entityNaturalIdResolutionCache = naturalIdResolutionCacheMap.get( persister );
if ( entityNaturalIdResolutionCache != null ) {
@ -423,8 +423,8 @@ public class NaturalIdXrefDelegate {
private static class NaturalIdResolutionCache implements Serializable {
private final EntityPersister persister;
private Map<Serializable, CachedNaturalId> pkToNaturalIdMap = new ConcurrentHashMap<>();
private Map<CachedNaturalId, Serializable> naturalIdToPkMap = new ConcurrentHashMap<>();
private Map<Object, CachedNaturalId> pkToNaturalIdMap = new ConcurrentHashMap<>();
private Map<CachedNaturalId, Object> naturalIdToPkMap = new ConcurrentHashMap<>();
private List<CachedNaturalId> invalidNaturalIdList;
@ -436,7 +436,7 @@ public class NaturalIdXrefDelegate {
return persister;
}
public boolean sameAsCached(Serializable pk, Object[] naturalIdValues) {
public boolean sameAsCached(Object pk, Object[] naturalIdValues) {
if ( pk == null ) {
return false;
}
@ -449,7 +449,7 @@ public class NaturalIdXrefDelegate {
return false;
}
public boolean cache(Serializable pk, Object[] naturalIdValues) {
public boolean cache(Object pk, Object[] naturalIdValues) {
if ( pk == null ) {
return false;
}

View File

@ -13,7 +13,6 @@ import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
@ -305,7 +304,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
* {@inheritDoc}
*/
@Override
public Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister) throws HibernateException {
public Object[] getDatabaseSnapshot(Object id, EntityPersister persister) throws HibernateException {
final EntityKey key = session.generateEntityKey( id, persister );
final Object cached = entitySnapshotsByKey.get( key );
if ( cached != null ) {
@ -319,7 +318,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister) throws HibernateException {
public Object[] getNaturalIdSnapshot(Object id, EntityPersister persister) throws HibernateException {
if ( !persister.hasNaturalIdentifier() ) {
return null;
}
@ -489,7 +488,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
final Status status,
final Object[] loadedState,
final Object rowId,
final Serializable id,
final Object id,
final Object version,
final LockMode lockMode,
final boolean existsInDatabase,
@ -599,7 +598,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public void reassociateProxy(Object value, Serializable id) throws MappingException {
public void reassociateProxy(Object value, Object id) throws MappingException {
if ( value instanceof HibernateProxy ) {
LOG.debugf( "Setting proxy identifier: %s", id );
final HibernateProxy proxy = (HibernateProxy) value;
@ -757,7 +756,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) throws MappingException {
public Object getCollectionOwner(Object key, CollectionPersister collectionPersister) throws MappingException {
// todo : we really just need to add a split in the notions of:
// 1) collection key
// 2) collection owner key
@ -771,11 +770,11 @@ public class StatefulPersistenceContext implements PersistenceContext {
//
// 1) The incoming key could be the entity itself...
if ( ownerPersister.isInstance( key ) ) {
final Serializable owenerId = ownerPersister.getIdentifier( key, session );
if ( owenerId == null ) {
final Object ownerId = ownerPersister.getIdentifier( key, session );
if ( ownerId == null ) {
return null;
}
return getEntity( session.generateEntityKey( owenerId, ownerPersister ) );
return getEntity( session.generateEntityKey( ownerId, ownerPersister ) );
}
final CollectionType collectionType = collectionPersister.getCollectionType();
@ -811,7 +810,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
// We could also possibly see if the referenced property is a natural id since we already have caching
// in place of natural id snapshots. BUt really its better to just do it the right way ^^ if we start
// going that route
final Serializable ownerId = ownerPersister.getIdByUniqueKey( key, collectionType.getLHSPropertyName(), session );
final Object ownerId = ownerPersister.getIdByUniqueKey( key, collectionType.getLHSPropertyName(), session );
return getEntity( session.generateEntityKey( ownerId, ownerPersister ) );
}
@ -829,7 +828,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
Object loadedOwner = null;
// TODO: an alternative is to check if the owner has changed; if it hasn't then
// return collection.getOwner()
final Serializable entityId = getLoadedCollectionOwnerIdOrNull( ce );
final Object entityId = getLoadedCollectionOwnerIdOrNull( ce );
if ( entityId != null ) {
loadedOwner = getCollectionOwner( entityId, ce.getLoadedPersister() );
}
@ -837,7 +836,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public Serializable getLoadedCollectionOwnerIdOrNull(PersistentCollection collection) {
public Object getLoadedCollectionOwnerIdOrNull(PersistentCollection collection) {
return getLoadedCollectionOwnerIdOrNull( getCollectionEntry( collection ) );
}
@ -847,7 +846,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
* @param ce The collection entry
* @return the owner ID if available from the collection's loaded key; otherwise, returns null
*/
private Serializable getLoadedCollectionOwnerIdOrNull(CollectionEntry ce) {
private Object getLoadedCollectionOwnerIdOrNull(CollectionEntry ce) {
if ( ce == null || ce.getLoadedKey() == null || ce.getLoadedPersister() == null ) {
return null;
}
@ -857,7 +856,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id) {
public void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Object id) {
final CollectionEntry ce = new CollectionEntry( collection, persister, id, flushing );
addCollection( collection, ce, id );
if ( persister.getBatchSize() > 1 ) {
@ -882,12 +881,8 @@ public class StatefulPersistenceContext implements PersistenceContext {
/**
* Add a collection to the cache, with a given collection entry.
*
* @param coll The collection for which we are adding an entry.
* @param entry The entry representing the collection.
* @param key The key of the collection's entry.
*/
private void addCollection(PersistentCollection coll, CollectionEntry entry, Serializable key) {
private void addCollection(PersistentCollection coll, CollectionEntry entry, Object key) {
getOrInitializeCollectionEntries().put( coll, entry );
final CollectionKey collectionKey = new CollectionKey( entry.getLoadedPersister(), key );
final PersistentCollection old = collectionsByKey.put( collectionKey, coll );
@ -937,7 +932,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public CollectionEntry addInitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id)
public CollectionEntry addInitializedCollection(CollectionPersister persister, PersistentCollection collection, Object id)
throws HibernateException {
final CollectionEntry ce = new CollectionEntry( collection, persister, id, flushing );
ce.postInitialize( collection );
@ -1200,7 +1195,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public Serializable getOwnerId(String entityName, String propertyName, Object childEntity, Map mergeMap) {
public Object getOwnerId(String entityName, String propertyName, Object childEntity, Map mergeMap) {
final String collectionRole = entityName + '.' + propertyName;
final EntityPersister persister = session.getFactory().getMetamodel().entityPersister( entityName );
final CollectionPersister collectionPersister = session.getFactory().getMetamodel().collectionPersister( collectionRole );
@ -1487,7 +1482,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId) {
public void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Object generatedId) {
final Object entity = entitiesByKey.remove( oldKey );
final EntityEntry oldEntry = entityEntryContext.removeEntityEntry( entity );
this.parentsByChild = null;
@ -1764,17 +1759,17 @@ public class StatefulPersistenceContext implements PersistenceContext {
// INSERTED KEYS HANDLING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private HashMap<String,List<Serializable>> insertedKeysMap;
private HashMap<String,List<Object>> insertedKeysMap;
@Override
public void registerInsertedKey(EntityPersister persister, Serializable id) {
public void registerInsertedKey(EntityPersister persister, Object id) {
// we only are worried about registering these if the persister defines caching
if ( persister.canWriteToCache() ) {
if ( insertedKeysMap == null ) {
insertedKeysMap = new HashMap<>();
}
final String rootEntityName = persister.getRootEntityName();
List<Serializable> insertedEntityIds = insertedKeysMap.get( rootEntityName );
List<Object> insertedEntityIds = insertedKeysMap.get( rootEntityName );
if ( insertedEntityIds == null ) {
insertedEntityIds = new ArrayList<>();
insertedKeysMap.put( rootEntityName, insertedEntityIds );
@ -1784,11 +1779,11 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public boolean wasInsertedDuringTransaction(EntityPersister persister, Serializable id) {
public boolean wasInsertedDuringTransaction(EntityPersister persister, Object id) {
// again, we only really care if the entity is cached
if ( persister.canWriteToCache() ) {
if ( insertedKeysMap != null ) {
final List<Serializable> insertedEntityIds = insertedKeysMap.get( persister.getRootEntityName() );
final List<Object> insertedEntityIds = insertedKeysMap.get( persister.getRootEntityName() );
if ( insertedEntityIds != null ) {
return insertedEntityIds.contains( id );
}
@ -1857,7 +1852,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override
public void cacheNaturalIdCrossReferenceFromLoad(
EntityPersister persister,
Serializable id,
Object id,
Object[] naturalIdValues) {
if ( !persister.hasNaturalIdentifier() ) {
// nothing to do
@ -1880,7 +1875,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override
public void manageLocalNaturalIdCrossReference(
EntityPersister persister,
Serializable id,
Object id,
Object[] state,
Object[] previousState,
CachedNaturalIdValueSource source) {
@ -1899,7 +1894,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override
public void manageSharedNaturalIdCrossReference(
EntityPersister persister,
final Serializable id,
final Object id,
Object[] state,
Object[] previousState,
CachedNaturalIdValueSource source) {
@ -1922,7 +1917,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
private void managedSharedCacheEntries(
EntityPersister persister,
final Serializable id,
final Object id,
Object[] naturalIdValues,
Object[] previousNaturalIdValues,
CachedNaturalIdValueSource source) {
@ -2041,7 +2036,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public Object[] removeLocalNaturalIdCrossReference(EntityPersister persister, Serializable id, Object[] state) {
public Object[] removeLocalNaturalIdCrossReference(EntityPersister persister, Object id, Object[] state) {
if ( !persister.hasNaturalIdentifier() ) {
// nothing to do
return null;
@ -2060,7 +2055,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public void removeSharedNaturalIdCrossReference(EntityPersister persister, Serializable id, Object[] naturalIdValues) {
public void removeSharedNaturalIdCrossReference(EntityPersister persister, Object id, Object[] naturalIdValues) {
if ( !persister.hasNaturalIdentifier() ) {
// nothing to do
return;
@ -2088,12 +2083,12 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public Object[] findCachedNaturalId(EntityPersister persister, Serializable pk) {
public Object[] findCachedNaturalId(EntityPersister persister, Object pk) {
return getNaturalIdXrefDelegate().findCachedNaturalId( locateProperPersister( persister ), pk );
}
@Override
public Serializable findCachedNaturalIdResolution(EntityPersister persister, Object[] naturalIdValues) {
public Object findCachedNaturalIdResolution(EntityPersister persister, Object[] naturalIdValues) {
return getNaturalIdXrefDelegate().findCachedNaturalIdResolution( locateProperPersister( persister ), naturalIdValues );
}
@ -2131,12 +2126,12 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
@Override
public Collection<Serializable> getCachedPkResolutions(EntityPersister entityPersister) {
public Collection<Object> getCachedPkResolutions(EntityPersister entityPersister) {
return getNaturalIdXrefDelegate().getCachedPkResolutions( entityPersister );
}
@Override
public void handleSynchronization(EntityPersister persister, Serializable pk, Object entity) {
public void handleSynchronization(EntityPersister persister, Object pk, Object entity) {
if ( !persister.hasNaturalIdentifier() ) {
// nothing to do
return;

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.engine.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.CacheMode;
import org.hibernate.HibernateException;
@ -65,8 +63,7 @@ public final class TwoPhaseLoad {
* Add the "hydrated state" (an array) of an uninitialized entity to the session. We don't try
* to resolve any associations yet, because there might be other entities waiting to be
* read from the JDBC result set we are currently processing
*
* @param persister The persister for the hydrated entity
* @param persister The persister for the hydrated entity
* @param id The entity identifier
* @param values The entity values
* @param rowId The rowId for the entity
@ -76,7 +73,7 @@ public final class TwoPhaseLoad {
*/
public static void postHydrate(
final EntityPersister persister,
final Serializable id,
final Object id,
final Object[] values,
final Object rowId,
final Object object,
@ -169,7 +166,7 @@ public final class TwoPhaseLoad {
final Iterable<PreLoadEventListener> preLoadEventListeners) throws HibernateException {
final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
final EntityPersister persister = entityEntry.getPersister();
final Serializable id = entityEntry.getId();
final Object id = entityEntry.getId();
final Object[] hydratedState = entityEntry.getLoadedState();
final boolean debugEnabled = LOG.isDebugEnabled();

View File

@ -13,12 +13,12 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Map.Entry;
import org.hibernate.EntityMode;
import org.hibernate.cache.spi.access.CollectionDataAccess;
import org.hibernate.cache.spi.access.EntityDataAccess;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.internal.CacheHelper;
import org.hibernate.internal.CoreLogging;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
@ -46,7 +46,7 @@ public class BatchFetchQueue {
/**
* Used to hold information about the entities that are currently eligible for batch-fetching. Ultimately
* used by {@link #getEntityBatch} to build entity load batches.
* used by {@link #getBatchLoadableEntityIds} to build entity load batches.
* <p/>
* A Map structure is used to segment the keys by entity type since loading can only be done for a particular entity
* type at a time.
@ -179,20 +179,15 @@ public class BatchFetchQueue {
* Get a batch of unloaded identifiers for this class, using a slightly
* complex algorithm that tries to grab keys registered immediately after
* the given key.
*
* @param persister The persister for the entities being loaded.
* @param id The identifier of the entity currently demanding load.
* @param batchSize The maximum number of keys to return
* @return an array of identifiers, of length batchSize (possibly padded with nulls)
*/
public Serializable[] getEntityBatch(
final EntityPersister persister,
final Serializable id,
final int batchSize,
final EntityMode entityMode) {
public Object[] getBatchLoadableEntityIds(
final EntityMappingType entityDescriptor,
final Object loadingId,
final int maxBatchSize) {
final Serializable[] ids = new Serializable[batchSize];
ids[0] = id; //first element of array is reserved for the actual instance we are loading!
final Object[] ids = new Object[maxBatchSize];
// make sure we load the id being loaded in the batch!
ids[0] = loadingId;
if ( batchLoadableEntityKeys == null ) {
return ids;
@ -204,22 +199,24 @@ public class BatchFetchQueue {
// TODO: this needn't exclude subclasses...
LinkedHashSet<EntityKey> set = batchLoadableEntityKeys.get( persister.getEntityName() );
LinkedHashSet<EntityKey> set = batchLoadableEntityKeys.get( entityDescriptor.getEntityName() );
if ( set != null ) {
for ( EntityKey key : set ) {
if ( checkForEnd && i == end ) {
//the first id found after the given id
// the first id found after the given id
return ids;
}
if ( persister.getIdentifierType().isEqual( id, key.getIdentifier() ) ) {
if ( entityDescriptor.getEntityPersister().getIdentifierType().isEqual( loadingId, key.getIdentifier() ) ) {
end = i;
}
else {
if ( !isCached( key, persister ) ) {
if ( !isCached( key, entityDescriptor.getEntityPersister() ) ) {
ids[i++] = key.getIdentifier();
}
}
if ( i == batchSize ) {
if ( i == maxBatchSize ) {
i = 1; // end of array, start filling again from start
if ( end != -1 ) {
checkForEnd = true;
@ -227,7 +224,9 @@ public class BatchFetchQueue {
}
}
}
return ids; //we ran out of ids to try
//we ran out of ids to try
return ids;
}
private boolean isCached(EntityKey entityKey, EntityPersister persister) {
@ -290,12 +289,12 @@ public class BatchFetchQueue {
* @param batchSize the maximum number of keys to return
* @return an array of collection keys, of length batchSize (padded with nulls)
*/
public Serializable[] getCollectionBatch(
public Object[] getCollectionBatch(
final CollectionPersister collectionPersister,
final Serializable id,
final Object id,
final int batchSize) {
final Serializable[] keys = new Serializable[batchSize];
final Object[] keys = new Object[batchSize];
keys[0] = id;
if ( batchLoadableCollections == null ) {
@ -357,7 +356,7 @@ public class BatchFetchQueue {
return keys; //we ran out of keys to try
}
private boolean isCached(Serializable collectionKey, CollectionPersister persister) {
private boolean isCached(Object collectionKey, CollectionPersister persister) {
SharedSessionContractImplementor session = context.getSession();
if ( session.getCacheMode().isGetEnabled() && persister.hasCache() ) {
CollectionDataAccess cache = persister.getCacheAccessStrategy();

View File

@ -41,7 +41,7 @@ public final class CollectionEntry implements Serializable {
// "loaded" means the reference that is consistent
// with the current database state
private transient CollectionPersister loadedPersister;
private Serializable loadedKey;
private Object loadedKey;
// ATTRIBUTES USED ONLY DURING FLUSH CYCLE
@ -58,7 +58,7 @@ public final class CollectionEntry implements Serializable {
// "current" means the reference that was found during flush()
private transient CollectionPersister currentPersister;
private transient Serializable currentKey;
private transient Object currentKey;
/**
* For newly wrapped collections, or dereferenced collection wrappers
@ -82,7 +82,7 @@ public final class CollectionEntry implements Serializable {
public CollectionEntry(
final PersistentCollection collection,
final CollectionPersister loadedPersister,
final Serializable loadedKey,
final Object loadedKey,
final boolean ignore ) {
this.ignore = ignore;
@ -99,7 +99,7 @@ public final class CollectionEntry implements Serializable {
/**
* For uninitialized detached collections
*/
public CollectionEntry(CollectionPersister loadedPersister, Serializable loadedKey) {
public CollectionEntry(CollectionPersister loadedPersister, Object loadedKey) {
// detached collection wrappers that get found + reattached
// during flush shouldn't be ignored
ignore = false;
@ -241,7 +241,7 @@ public final class CollectionEntry implements Serializable {
collection.postAction();
}
public Serializable getKey() {
public Object getKey() {
return getLoadedKey();
}
@ -343,11 +343,11 @@ public final class CollectionEntry implements Serializable {
* This is only available late during the flush
* cycle
*/
public Serializable getCurrentKey() {
public Object getCurrentKey() {
return currentKey;
}
public void setCurrentKey(Serializable currentKey) {
public void setCurrentKey(Object currentKey) {
this.currentKey = currentKey;
}
@ -358,7 +358,7 @@ public final class CollectionEntry implements Serializable {
return loadedPersister;
}
public Serializable getLoadedKey() {
public Object getLoadedKey() {
return loadedKey;
}

View File

@ -8,7 +8,6 @@ package org.hibernate.engine.spi;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.hibernate.LockMode;
import org.hibernate.collection.spi.PersistentCollection;
@ -34,7 +33,7 @@ public interface EntityEntry {
void setStatus(Status status);
Serializable getId();
Object getId();
Object[] getLoadedState();

View File

@ -25,7 +25,7 @@ public interface EntityEntryFactory extends Serializable {
final Status status,
final Object[] loadedState,
final Object rowId,
final Serializable id,
final Object id,
final Object version,
final LockMode lockMode,
final boolean existsInDatabase,

View File

@ -122,7 +122,7 @@ public interface PersistenceContext {
*
* @see #getCachedDatabaseSnapshot
*/
Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister);
Object[] getDatabaseSnapshot(Object id, EntityPersister persister);
/**
* Retrieve the cached database snapshot for the requested entity key.
@ -146,7 +146,7 @@ public interface PersistenceContext {
*
* @return The current (non-cached) snapshot of the entity's natural id state.
*/
Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister);
Object[] getNaturalIdSnapshot(Object id, EntityPersister persister);
/**
* Add a canonical mapping from entity key to entity instance
@ -257,7 +257,7 @@ public interface PersistenceContext {
final Status status,
final Object[] loadedState,
final Object rowId,
final Serializable id,
final Object id,
final Object version,
final LockMode lockMode,
final boolean existsInDatabase,
@ -281,20 +281,20 @@ public interface PersistenceContext {
* @return Whether the passed value represented an actual proxy which got initialized.
* @throws MappingException
*/
boolean reassociateIfUninitializedProxy(Object value) throws MappingException;
boolean reassociateIfUninitializedProxy(Object value) ;
/**
* If a deleted entity instance is re-saved, and it has a proxy, we need to
* reset the identifier of the proxy
*/
void reassociateProxy(Object value, Serializable id) throws MappingException;
void reassociateProxy(Object value, Object id);
/**
* Get the entity instance underlying the given proxy, throwing
* an exception if the proxy is uninitialized. If the given object
* is not a proxy, simply return the argument.
*/
Object unproxy(Object maybeProxy) throws HibernateException;
Object unproxy(Object maybeProxy);
/**
* Possibly unproxy the given reference and reassociate it with the current session.
@ -303,7 +303,7 @@ public interface PersistenceContext {
* @return The unproxied instance.
* @throws HibernateException
*/
Object unproxyAndReassociate(Object maybeProxy) throws HibernateException;
Object unproxyAndReassociate(Object maybeProxy);
/**
* Attempts to check whether the given key represents an entity already loaded within the
@ -313,7 +313,7 @@ public interface PersistenceContext {
*
* @throws HibernateException
*/
void checkUniqueness(EntityKey key, Object object) throws HibernateException;
void checkUniqueness(EntityKey key, Object object);
/**
* If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy
@ -328,23 +328,21 @@ public interface PersistenceContext {
* @return An appropriately narrowed instance.
* @throws HibernateException
*/
Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object)
throws HibernateException;
Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object);
/**
* Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
* third argument (the entity associated with the key) if no proxy exists. Init
* the proxy to the target implementation, if necessary.
*/
Object proxyFor(EntityPersister persister, EntityKey key, Object impl)
throws HibernateException;
Object proxyFor(EntityPersister persister, EntityKey key, Object impl);
/**
* Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
* argument (the entity associated with the key) if no proxy exists.
* (slower than the form above)
*/
Object proxyFor(Object impl) throws HibernateException;
Object proxyFor(Object impl);
/**
* Cross between {@link #addEntity(EntityKey, Object)} and {@link #addProxy(EntityKey, Object)}
@ -355,8 +353,7 @@ public interface PersistenceContext {
/**
* Get the entity that owns this persistent collection
*/
Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister)
throws MappingException;
Object getCollectionOwner(Object key, CollectionPersister collectionPersister);
/**
* Get the entity that owned this persistent collection when it was loaded
@ -373,27 +370,24 @@ public interface PersistenceContext {
* @param collection The persistent collection
* @return the owner ID if available from the collection's loaded key; otherwise, returns null
*/
Serializable getLoadedCollectionOwnerIdOrNull(PersistentCollection collection);
Object getLoadedCollectionOwnerIdOrNull(PersistentCollection collection);
/**
* add a collection we just loaded up (still needs initializing)
*/
void addUninitializedCollection(CollectionPersister persister,
PersistentCollection collection, Serializable id);
void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Object id);
/**
* add a detached uninitialized collection
*/
void addUninitializedDetachedCollection(CollectionPersister persister,
PersistentCollection collection);
void addUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection);
/**
* Add a new collection (ie. a newly created one, just instantiated by the
* application, with no database state or snapshot)
* @param collection The collection to be associated with the persistence context
*/
void addNewCollection(CollectionPersister persister, PersistentCollection collection)
throws HibernateException;
void addNewCollection(CollectionPersister persister, PersistentCollection collection);
/**
* add an (initialized) collection that was created by another session and passed
@ -409,7 +403,7 @@ public interface PersistenceContext {
CollectionEntry addInitializedCollection(
CollectionPersister persister,
PersistentCollection collection,
Serializable id);
Object id);
/**
* Get the collection instance associated with the <tt>CollectionKey</tt>
@ -603,7 +597,7 @@ public interface PersistenceContext {
* @return The id of the entityName instance which is said to own the child; null if an appropriate owner not
* located.
*/
Serializable getOwnerId(String entityName, String propertyName, Object childEntity, Map mergeMap);
Object getOwnerId(String entityName, String propertyName, Object childEntity, Map mergeMap);
/**
* Search the persistence context for an index of the child object,
@ -658,7 +652,7 @@ public interface PersistenceContext {
*
* To override this session's read-only/modifiable setting for entities
* and proxies loaded by a Query:
* @see org.hibernate.Query#setReadOnly(boolean)
* @see org.hibernate.query.Query#setReadOnly(boolean)
*
* @param readOnly true, the default for loaded entities/proxies is read-only;
* false, the default for loaded entities/proxies is modifiable
@ -701,11 +695,11 @@ public interface PersistenceContext {
*
* @see org.hibernate.Session#setDefaultReadOnly
* @see org.hibernate.Session#setReadOnly
* @see org.hibernate.Query#setReadOnly
* @see org.hibernate.query.Query#setReadOnly
*/
void setReadOnly(Object entityOrProxy, boolean readOnly);
void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId);
void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Object generatedId);
/**
* Add a child/parent relation to cache for cascading op
@ -724,11 +718,10 @@ public interface PersistenceContext {
/**
* Register keys inserted during the current transaction
*
* @param persister The entity persister
* @param persister The entity persister
* @param id The id
*/
void registerInsertedKey(EntityPersister persister, Serializable id);
void registerInsertedKey(EntityPersister persister, Object id);
/**
* Allows callers to check to see if the identified entity was inserted during the current transaction.
@ -738,7 +731,7 @@ public interface PersistenceContext {
*
* @return True if inserted during this transaction, false otherwise.
*/
boolean wasInsertedDuringTransaction(EntityPersister persister, Serializable id);
boolean wasInsertedDuringTransaction(EntityPersister persister, Object id);
/**
* Checks if a certain {@link EntityKey} was registered as nullifiable on this {@link PersistenceContext}.
@ -805,102 +798,68 @@ public interface PersistenceContext {
/**
* Performs processing related to creating natural-id cross-reference entries on load.
* Handles both the local (transactional) and shared (second-level) caches.
*
* @param persister The persister representing the entity type.
* @param persister The persister representing the entity type.
* @param id The primary key value
* @param naturalIdValues The natural id values
*/
void cacheNaturalIdCrossReferenceFromLoad(
EntityPersister persister,
Serializable id,
Object id,
Object[] naturalIdValues);
/**
* Creates necessary local cross-reference entries.
*
* @param persister The persister representing the entity type.
* @param persister The persister representing the entity type.
* @param id The primary key value
* @param state Generally the "full entity state array", though could also be the natural id values array
* @param previousState Generally the "full entity state array", though could also be the natural id values array.
* Specifically represents the previous values on update, and so is only used with {@link CachedNaturalIdValueSource#UPDATE}
* @param previousState Generally the "full entity state array", though could also be the natural id values array.
* Specifically represents the previous values on update, and so is only used with {@link CachedNaturalIdValueSource#UPDATE}
* @param source Enumeration representing how these values are coming into cache.
*/
void manageLocalNaturalIdCrossReference(
EntityPersister persister,
Serializable id,
Object id,
Object[] state,
Object[] previousState,
CachedNaturalIdValueSource source);
/**
* Cleans up local cross-reference entries.
*
* @param persister The persister representing the entity type.
* @param id The primary key value
* @param state Generally the "full entity state array", though could also be the natural id values array
*
* @return The local cached natural id values (could be different from given values).
*/
Object[] removeLocalNaturalIdCrossReference(EntityPersister persister, Serializable id, Object[] state);
Object[] removeLocalNaturalIdCrossReference(EntityPersister persister, Object id, Object[] state);
/**
* Creates necessary shared (second level cache) cross-reference entries.
*
* @param persister The persister representing the entity type.
* @param id The primary key value
* @param state Generally the "full entity state array", though could also be the natural id values array
* @param previousState Generally the "full entity state array", though could also be the natural id values array.
* Specifically represents the previous values on update, and so is only used with {@link CachedNaturalIdValueSource#UPDATE}
* @param source Enumeration representing how these values are coming into cache.
*/
void manageSharedNaturalIdCrossReference(
EntityPersister persister,
Serializable id,
Object id,
Object[] state,
Object[] previousState,
CachedNaturalIdValueSource source);
/**
* Cleans up local cross-reference entries.
*
* @param persister The persister representing the entity type.
* @param id The primary key value
* @param naturalIdValues The natural id values array
*/
void removeSharedNaturalIdCrossReference(EntityPersister persister, Serializable id, Object[] naturalIdValues);
void removeSharedNaturalIdCrossReference(EntityPersister persister, Object id, Object[] naturalIdValues);
/**
* Given a persister and primary key, find the corresponding cross-referenced natural id values.
*
* @param persister The persister representing the entity type.
* @param pk The primary key value
*
* @return The cross-referenced natural-id values, or {@code null}
*/
Object[] findCachedNaturalId(EntityPersister persister, Serializable pk);
Object[] findCachedNaturalId(EntityPersister persister, Object pk);
/**
* Given a persister and natural-id values, find the corresponding cross-referenced primary key. Will return
* {@link PersistenceContext.NaturalIdHelper#INVALID_NATURAL_ID_REFERENCE} if the given natural ids are known to
* be invalid.
*
* @param persister The persister representing the entity type.
* @param naturalIdValues The natural id value(s)
*
* @return The corresponding cross-referenced primary key,
* {@link PersistenceContext.NaturalIdHelper#INVALID_NATURAL_ID_REFERENCE},
* or {@code null}.
*/
Serializable findCachedNaturalIdResolution(EntityPersister persister, Object[] naturalIdValues);
Object findCachedNaturalIdResolution(EntityPersister persister, Object[] naturalIdValues);
/**
* Find all the locally cached primary key cross-reference entries for the given persister.
*
* @param persister The persister representing the entity type.
*
* @return The primary keys
* @return
*/
Collection<Serializable> getCachedPkResolutions(EntityPersister persister);
Collection<?> getCachedPkResolutions(EntityPersister persister);
/**
* Part of the "load synchronization process". Responsible for maintaining cross-reference entries
@ -912,10 +871,10 @@ public interface PersistenceContext {
* @param persister The persister representing the entity type.
* @param pk The primary key
* @param entity The entity instance
*
*
* @see #cleanupFromSynchronizations
*/
void handleSynchronization(EntityPersister persister, Serializable pk, Object entity);
void handleSynchronization(EntityPersister persister, Object pk, Object entity);
/**
* The clean up process of {@link #handleSynchronization}. Responsible for cleaning up the tracking

View File

@ -85,6 +85,13 @@ public final class QueryParameters {
this( positionalParameterTypes, positionalParameterValues, null, null, false, false, false, null, null, null, false, null );
}
public QueryParameters(
final Type[] positionalParameterTypes,
final Object[] positionalParameterValues,
final Object[] collectionKeys) {
this( positionalParameterTypes, positionalParameterValues, null, (Serializable[]) collectionKeys );
}
public QueryParameters(
final Type[] positionalParameterTypes,
final Object[] positionalParameterValues,

View File

@ -113,7 +113,7 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public EntityKey generateEntityKey(Serializable id, EntityPersister persister) {
public EntityKey generateEntityKey(Object id, EntityPersister persister) {
return delegate.generateEntityKey( id, persister );
}
@ -143,12 +143,12 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException {
public Object internalLoad(String entityName, Object id, boolean eager, boolean nullable) throws HibernateException {
return delegate.internalLoad( entityName, id, eager, nullable );
}
@Override
public Object immediateLoad(String entityName, Serializable id) throws HibernateException {
public Object immediateLoad(String entityName, Object id) throws HibernateException {
return delegate.immediateLoad( entityName, id );
}
@ -173,7 +173,7 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public Serializable getContextEntityIdentifier(Object object) {
public Object getContextEntityIdentifier(Object object) {
return delegate.getContextEntityIdentifier( object );
}
@ -642,7 +642,7 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public Serializable getIdentifier(Object object) {
public Object getIdentifier(Object object) {
return delegate.getIdentifier( object );
}
@ -677,37 +677,37 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public <T> T load(Class<T> theClass, Serializable id, LockMode lockMode) {
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, Serializable id, LockOptions lockOptions) {
public <T> T load(Class<T> theClass, Object id, LockOptions lockOptions) {
return delegate.load( theClass, id, lockOptions );
}
@Override
public Object load(String entityName, Serializable id, LockMode lockMode) {
public Object load(String entityName, Object id, LockMode lockMode) {
return delegate.load( entityName, id, lockMode );
}
@Override
public Object load(String entityName, Serializable id, LockOptions lockOptions) {
public Object load(String entityName, Object id, LockOptions lockOptions) {
return delegate.load( entityName, id, lockOptions );
}
@Override
public <T> T load(Class<T> theClass, Serializable id) {
public <T> T load(Class<T> theClass, Object id) {
return delegate.load( theClass, id );
}
@Override
public Object load(String entityName, Serializable id) {
public Object load(String entityName, Object id) {
return delegate.load( entityName, id );
}
@Override
public void load(Object object, Serializable id) {
public void load(Object object, Object id) {
delegate.load( object, id );
}
@ -722,12 +722,12 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public Serializable save(Object object) {
public Object save(Object object) {
return delegate.save( object );
}
@Override
public Serializable save(String entityName, Object object) {
public Object save(String entityName, Object object) {
return delegate.save( entityName, object );
}
@ -882,22 +882,22 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public <T> T get(Class<T> theClass, Serializable id) {
public <T> T get(Class<T> theClass, Object id) {
return delegate.get( theClass, id );
}
@Override
public <T> T get(Class<T> theClass, Serializable id, LockMode lockMode) {
public <T> T get(Class<T> theClass, Object id, LockMode lockMode) {
return delegate.get( theClass, id, lockMode );
}
@Override
public <T> T get(Class<T> theClass, Serializable id, LockOptions lockOptions) {
public <T> T get(Class<T> theClass, Object id, LockOptions lockOptions) {
return delegate.get( theClass, id, lockOptions );
}
@Override
public Object get(String entityName, Serializable id) {
public Object get(String entityName, Object id) {
return delegate.get( entityName, id );
}
@ -907,7 +907,7 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public Object get(String entityName, Serializable id, LockOptions lockOptions) {
public Object get(String entityName, Object id, LockOptions lockOptions) {
return delegate.get( entityName, id, lockOptions );
}
@ -1042,7 +1042,7 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
}
@Override
public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException {
public Object instantiate(EntityPersister persister, Object id) throws HibernateException {
return delegate.instantiate( persister, id );
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.engine.spi;
import java.io.Serializable;
import java.util.Map;
import java.util.Set;
import javax.persistence.criteria.CriteriaDelete;
@ -79,7 +78,7 @@ public interface SessionImplementor extends Session, SharedSessionContractImplem
ActionQueue getActionQueue();
Object instantiate(EntityPersister persister, Serializable id) throws HibernateException;
Object instantiate(EntityPersister persister, Object id) throws HibernateException;
void forceFlush(EntityEntry e) throws HibernateException;

View File

@ -224,7 +224,7 @@ public interface SharedSessionContractImplementor
*
* @return The entity key
*/
EntityKey generateEntityKey(Serializable id, EntityPersister persister);
EntityKey generateEntityKey(Object id, EntityPersister persister);
/**
* Retrieves the interceptor currently in use by this event source.
@ -257,14 +257,14 @@ public interface SharedSessionContractImplementor
* <p/>
* When <tt>eager</tt> is enabled, the object is eagerly fetched
*/
Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable)
Object internalLoad(String entityName, Object id, boolean eager, boolean nullable)
throws HibernateException;
/**
* Load an instance immediately. This method is only called when lazily initializing a proxy.
* Do not return the proxy.
*/
Object immediateLoad(String entityName, Serializable id) throws HibernateException;
Object immediateLoad(String entityName, Object id) throws HibernateException;
/**
@ -284,8 +284,9 @@ public interface SharedSessionContractImplementor
/**
* Return the identifier of the persistent object, or null if
* not associated with the session
* @return
*/
Serializable getContextEntityIdentifier(Object object);
Object getContextEntityIdentifier(Object object);
/**
* The best guess entity name for an entity not in an association

View File

@ -266,7 +266,7 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
persistenceContext.forEachCollectionEntry(
(coll, ce) -> {
if ( ce.isDorecreate() ) {
interceptor.onCollectionRecreate( coll, ce.getCurrentKey() );
interceptor.onCollectionRecreate( coll, (Serializable) ce.getCurrentKey() );
actionQueue.addAction(
new CollectionRecreateAction(
coll,
@ -277,7 +277,7 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
);
}
if ( ce.isDoremove() ) {
interceptor.onCollectionRemove( coll, ce.getLoadedKey() );
interceptor.onCollectionRemove( coll, (Serializable) ce.getLoadedKey() );
actionQueue.addAction(
new CollectionRemoveAction(
coll,
@ -289,7 +289,7 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
);
}
if ( ce.isDoupdate() ) {
interceptor.onCollectionUpdate( coll, ce.getLoadedKey() );
interceptor.onCollectionUpdate( coll, (Serializable) ce.getLoadedKey() );
actionQueue.addAction(
new CollectionUpdateAction(
coll,

View File

@ -43,7 +43,7 @@ public abstract class AbstractReassociateEventListener implements Serializable {
*
* @return An EntityEntry representing the entity within this session.
*/
protected final EntityEntry reassociate(AbstractEvent event, Object object, Serializable id, EntityPersister persister) {
protected final EntityEntry reassociate(AbstractEvent event, Object object, Object id, EntityPersister persister) {
if ( log.isTraceEnabled() ) {
log.tracev(

View File

@ -70,9 +70,9 @@ public abstract class AbstractSaveEventListener
*
* @return The id used to save the entity.
*/
protected Serializable saveWithRequestedId(
protected Object saveWithRequestedId(
Object entity,
Serializable requestedId,
Object requestedId,
String entityName,
Object anything,
EventSource source) {
@ -104,7 +104,7 @@ public abstract class AbstractSaveEventListener
* @return The id used to save the entity; may be null depending on the
* type of id generator used and the requiresImmediateIdAccess value
*/
protected Serializable saveWithGeneratedId(
protected Object saveWithGeneratedId(
Object entity,
String entityName,
Object anything,
@ -117,7 +117,7 @@ public abstract class AbstractSaveEventListener
}
EntityPersister persister = source.getEntityPersister( entityName, entity );
Serializable generatedId = persister.getIdentifierGenerator().generate( source, entity );
Object generatedId = persister.getIdentifierGenerator().generate( source, entity );
if ( generatedId == null ) {
throw new IdentifierGenerationException( "null id generated for:" + entity.getClass() );
}
@ -159,9 +159,9 @@ public abstract class AbstractSaveEventListener
* @return The id used to save the entity; may be null depending on the
* type of id generator used and the requiresImmediateIdAccess value
*/
protected Serializable performSave(
protected Object performSave(
Object entity,
Serializable id,
Object id,
EntityPersister persister,
boolean useIdentityColumn,
Object anything,
@ -235,7 +235,7 @@ public abstract class AbstractSaveEventListener
* @return The id used to save the entity; may be null depending on the
* type of id generator used and the requiresImmediateIdAccess value
*/
protected Serializable performSaveOrReplicate(
protected Object performSaveOrReplicate(
Object entity,
EntityKey key,
EntityPersister persister,
@ -244,7 +244,7 @@ public abstract class AbstractSaveEventListener
EventSource source,
boolean requiresImmediateIdAccess) {
Serializable id = key == null ? null : key.getIdentifier();
Object id = key == null ? null : key.getIdentifier();
boolean inTrx = source.isTransactionInProgress();
boolean shouldDelayIdentityInserts = !inTrx && !requiresImmediateIdAccess;
@ -289,15 +289,21 @@ public abstract class AbstractSaveEventListener
source
);
AbstractEntityInsertAction insert = addInsertAction(
values, id, entity, persister, useIdentityColumn, source, shouldDelayIdentityInserts
final AbstractEntityInsertAction insert = addInsertAction(
values,
id,
entity,
persister,
useIdentityColumn,
source,
shouldDelayIdentityInserts
);
// postpone initializing id in case the insert has non-nullable transient dependencies
// that are not resolved until cascadeAfterSave() is executed
cascadeAfterSave( source, persister, entity, anything );
if ( useIdentityColumn && insert.isEarlyInsert() ) {
if ( !EntityIdentityInsertAction.class.isInstance( insert ) ) {
if ( !(insert instanceof EntityIdentityInsertAction) ) {
throw new IllegalStateException(
"Insert should be using an identity column, but action is of unexpected type: " +
insert.getClass().getName()
@ -322,7 +328,7 @@ public abstract class AbstractSaveEventListener
private AbstractEntityInsertAction addInsertAction(
Object[] values,
Serializable id,
Object id,
Object entity,
EntityPersister persister,
boolean useIdentityColumn,
@ -336,9 +342,15 @@ public abstract class AbstractSaveEventListener
return insert;
}
else {
Object version = Versioning.getVersion( values, persister );
EntityInsertAction insert = new EntityInsertAction(
id, values, entity, version, persister, isVersionIncrementDisabled(), source
final Object version = Versioning.getVersion( values, persister );
final EntityInsertAction insert = new EntityInsertAction(
id,
values,
entity,
version,
persister,
isVersionIncrementDisabled(),
source
);
source.getActionQueue().addAction( insert );
return insert;
@ -362,7 +374,7 @@ public abstract class AbstractSaveEventListener
protected boolean visitCollectionsBeforeSave(
Object entity,
Serializable id,
Object id,
Object[] values,
Type[] types,
EventSource source) {
@ -387,13 +399,13 @@ public abstract class AbstractSaveEventListener
*/
protected boolean substituteValuesIfNecessary(
Object entity,
Serializable id,
Object id,
Object[] values,
EntityPersister persister,
SessionImplementor source) {
boolean substitute = source.getInterceptor().onSave(
entity,
id,
(Serializable) id,
values,
persister.getPropertyNames(),
persister.getPropertyTypes()

View File

@ -89,7 +89,7 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback
EntityEntry entityEntry = persistenceContext.getEntry( entity );
final EntityPersister persister;
final Serializable id;
final Object id;
final Object version;
if ( entityEntry == null ) {
@ -191,7 +191,7 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback
EventSource source = event.getSession();
String entityName = event.getEntityName();
EntityPersister persister = source.getEntityPersister( entityName, event.getObject() );
Serializable id = persister.getIdentifier( event.getObject(), source );
Object id = persister.getIdentifier( event.getObject(), source );
entityName = entityName == null ? source.guessEntityName( event.getObject() ) : entityName;
throw new IllegalArgumentException("Removing a detached instance "+ entityName + "#" + id);
}
@ -273,7 +273,7 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback
session.getInterceptor().onDelete(
entity,
entityEntry.getId(),
(Serializable) entityEntry.getId(),
deletedState,
persister.getPropertyNames(),
propTypes

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.engine.internal.Cascade;
import org.hibernate.engine.internal.CascadePoint;
@ -54,7 +52,7 @@ public class DefaultEvictEventListener implements EvictEventListener {
if ( object instanceof HibernateProxy ) {
final LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
final Serializable id = li.getIdentifier();
final Object id = li.getIdentifier();
if ( id == null ) {
throw new IllegalArgumentException( "Could not determine identifier of proxy passed to evict()" );
}

View File

@ -60,21 +60,22 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
/**
* make sure user didn't mangle the id
*/
public void checkId(Object object, EntityPersister persister, Serializable id, SessionImplementor session)
public void checkId(Object object, EntityPersister persister, Object id, SessionImplementor session)
throws HibernateException {
if ( id != null && id instanceof DelayedPostInsertIdentifier ) {
if ( id instanceof DelayedPostInsertIdentifier ) {
// this is a situation where the entity id is assigned by a post-insert generator
// and was saved outside the transaction forcing it to be delayed
return;
}
if ( persister.canExtractIdOutOfEntity() ) {
final Object oid = persister.getIdentifier( object, session );
Serializable oid = persister.getIdentifier( object, session );
if ( id == null ) {
throw new AssertionFailure( "null id in " + persister.getEntityName() + " entry (don't flush the Session after an exception occurs)" );
}
if ( !persister.getIdentifierType().isEqual( id, oid, session.getFactory() ) ) {
throw new HibernateException(
"identifier of an instance of " + persister.getEntityName() + " was altered from "
@ -82,7 +83,6 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
);
}
}
}
private void checkNaturalId(
@ -370,7 +370,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
final boolean answerFromInterceptor = session.getInterceptor().onFlushDirty(
entity,
entry.getId(),
(Serializable) entry.getId(),
values,
entry.getLoadedState(),
persister.getPropertyNames(),
@ -511,12 +511,12 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
final SessionImplementor session = event.getSession();
final EntityEntry entry = event.getEntityEntry();
final EntityPersister persister = entry.getPersister();
final Serializable id = entry.getId();
final Object id = entry.getId();
final Object[] loadedState = entry.getLoadedState();
int[] dirtyProperties = session.getInterceptor().findDirty(
entity,
id,
(Serializable) id,
values,
loadedState,
persister.getPropertyNames(),
@ -606,7 +606,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
}
else {
// dirty check against the database snapshot, if possible/necessary
final Object[] databaseSnapshot = getDatabaseSnapshot( session, persister, id );
final Object[] databaseSnapshot = getDatabaseSnapshot( persister, id, session );
if ( databaseSnapshot != null ) {
dirtyProperties = persister.findModified( databaseSnapshot, values, entity, session );
dirtyCheckPossible = true;
@ -673,7 +673,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
@Override
public Object getLoadedValue() {
if ( databaseSnapshot == null ) {
databaseSnapshot = getDatabaseSnapshot( event.getSession(), persister, event.getEntityEntry().getId() );
databaseSnapshot = getDatabaseSnapshot( persister, event.getEntityEntry().getId(), event.getSession() );
}
return databaseSnapshot[index];
}
@ -693,7 +693,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
}
}
private void logDirtyProperties(Serializable id, int[] dirtyProperties, EntityPersister persister) {
private void logDirtyProperties(Object id, int[] dirtyProperties, EntityPersister persister) {
if ( dirtyProperties != null && dirtyProperties.length > 0 && LOG.isTraceEnabled() ) {
final String[] allPropertyNames = persister.getPropertyNames();
final String[] dirtyPropertyNames = new String[dirtyProperties.length];
@ -708,17 +708,18 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
}
}
private Object[] getDatabaseSnapshot(SessionImplementor session, EntityPersister persister, Serializable id) {
private Object[] getDatabaseSnapshot(
EntityPersister persister,
Object id,
SessionImplementor session) {
final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
if ( persister.isSelectBeforeUpdateRequired() ) {
Object[] snapshot = persistenceContext
.getDatabaseSnapshot( id, persister );
Object[] snapshot = persistenceContext.getDatabaseSnapshot( id, persister );
if ( snapshot == null ) {
//do we even really need this? the update will fail anyway....
final StatisticsImplementor statistics = session.getFactory().getStatistics();
if ( statistics.isStatisticsEnabled() ) {
statistics
.optimisticFailure( persister.getEntityName() );
statistics.optimisticFailure( persister.getEntityName() );
}
throw new StaleObjectStateException( persister.getEntityName(), id );
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.cache.spi.access.CollectionDataAccess;
import org.hibernate.cache.spi.entry.CollectionCacheEntry;
@ -100,7 +98,7 @@ public class DefaultInitializeCollectionEventListener implements InitializeColle
* false otherwise.
*/
private boolean initializeCollectionFromCache(
Serializable id,
Object id,
CollectionPersister persister,
PersistentCollection collection,
SessionImplementor source) {

View File

@ -67,7 +67,7 @@ public class DefaultLoadEventListener implements LoadEventListener {
final Class idClass = persister.getIdentifierType().getReturnedClass();
if ( idClass != null &&
!idClass.isInstance( event.getEntityId() ) &&
!DelayedPostInsertIdentifier.class.isInstance( event.getEntityId() ) ) {
!(event.getEntityId() instanceof DelayedPostInsertIdentifier) ) {
checkIdClass( persister, event, loadType, idClass );
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.TransientObjectException;
@ -68,7 +66,7 @@ public class DefaultLockEventListener extends AbstractLockUpgradeEventListener i
EntityEntry entry = persistenceContext.getEntry(entity);
if (entry==null) {
final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
final Serializable id = persister.getIdentifier( entity, source );
final Object id = persister.getIdentifier( entity, source );
if ( !ForeignKeys.isNotTransient( event.getEntityName(), entity, Boolean.FALSE, source ) ) {
throw new TransientObjectException(
"cannot lock an unsaved transient instance: " +

View File

@ -24,7 +24,6 @@ import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
import org.hibernate.loader.spi.InternalFetchProfile;
import org.hibernate.engine.spi.SelfDirtinessTracker;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
@ -35,6 +34,7 @@ import org.hibernate.event.spi.MergeEvent;
import org.hibernate.event.spi.MergeEventListener;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.loader.spi.InternalFetchProfile;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
@ -148,7 +148,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
EntityEntry entry = persistenceContext.getEntry( entity );
if ( entry == null ) {
EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
Serializable id = persister.getIdentifier( entity, source );
Object id = persister.getIdentifier( entity, source );
if ( id != null ) {
final EntityKey key = source.generateEntityKey( id, persister );
final Object managedEntity = persistenceContext.getEntity( key );
@ -218,7 +218,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
final String entityName = event.getEntityName();
final EntityPersister persister = session.getEntityPersister( entityName, entity );
final Serializable id = persister.hasIdentifierProperty()
final Object id = persister.hasIdentifierProperty()
? persister.getIdentifier( entity, session )
: null;
@ -286,13 +286,13 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
final String entityName = persister.getEntityName();
Serializable id = event.getRequestedId();
Object id = event.getRequestedId();
if ( id == null ) {
id = persister.getIdentifier( entity, source );
}
else {
// check that entity id = requestedId
Serializable entityId = persister.getIdentifier( entity, source );
Object entityId = persister.getIdentifier( entity, source );
if ( !persister.getIdentifierType().isEqual( id, entityId, source.getFactory() ) ) {
throw new HibernateException( "merge requested with id not matching id of passed entity" );
}
@ -432,7 +432,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
final PersistenceContext persistenceContext = source.getPersistenceContextInternal();
EntityEntry entry = persistenceContext.getEntry( entity );
if ( entry == null ) {
Serializable id = persister.getIdentifier( entity, source );
Object id = persister.getIdentifier( entity, source );
if ( id != null ) {
final EntityKey key = source.generateEntityKey( id, persister );
final Object managedEntity = persistenceContext.getEntity( key );

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.LockMode;
import org.hibernate.action.internal.EntityIncrementVersionProcess;
@ -69,7 +71,7 @@ public class DefaultPostLoadEventListener implements PostLoadEventListener, Call
if ( event.getPersister().implementsLifecycle() ) {
//log.debug( "calling onLoad()" );
( (Lifecycle) event.getEntity() ).onLoad( session, event.getId() );
( (Lifecycle) event.getEntity() ).onLoad( session, (Serializable) event.getId() );
}
}

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.event.spi.PreLoadEvent;
import org.hibernate.event.spi.PreLoadEventListener;
import org.hibernate.persister.entity.EntityPersister;
@ -19,16 +21,14 @@ import org.hibernate.persister.entity.EntityPersister;
public class DefaultPreLoadEventListener implements PreLoadEventListener {
public void onPreLoad(PreLoadEvent event) {
EntityPersister persister = event.getPersister();
event.getSession()
.getInterceptor()
.onLoad(
event.getEntity(),
event.getId(),
event.getState(),
persister.getPropertyNames(),
persister.getPropertyTypes()
);
final EntityPersister persister = event.getPersister();
event.getSession().getInterceptor().onLoad(
event.getEntity(),
(Serializable) event.getId(),
event.getState(),
persister.getPropertyNames(),
persister.getPropertyTypes()
);
}
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import java.util.IdentityHashMap;
import java.util.Map;
@ -85,13 +84,11 @@ public class DefaultRefreshEventListener implements RefreshEventListener {
final EntityEntry e = persistenceContext.getEntry( object );
final EntityPersister persister;
final Serializable id;
final Object id;
if ( e == null ) {
persister = source.getEntityPersister(
event.getEntityName(),
object
); //refresh() does not pass an entityName
//refresh() does not pass an entityName
persister = source.getEntityPersister( event.getEntityName(), object );
id = persister.getIdentifier( object, event.getSession() );
if ( LOG.isTraceEnabled() ) {
LOG.tracev(
@ -187,7 +184,7 @@ public class DefaultRefreshEventListener implements RefreshEventListener {
Object object,
EntityEntry e,
EntityPersister persister,
Serializable id,
Object id,
PersistenceContext persistenceContext) {
// Handle the requested lock-mode (if one) in relation to the entry's (if one) current lock-mode
@ -248,11 +245,11 @@ public class DefaultRefreshEventListener implements RefreshEventListener {
return result;
}
private void evictCachedCollections(EntityPersister persister, Serializable id, EventSource source) {
private void evictCachedCollections(EntityPersister persister, Object id, EventSource source) {
evictCachedCollections( persister.getPropertyTypes(), id, source );
}
private void evictCachedCollections(Type[] types, Serializable id, EventSource source)
private void evictCachedCollections(Type[] types, Object id, EventSource source)
throws HibernateException {
final ActionQueue actionQueue = source.getActionQueue();
final SessionFactoryImplementor factory = source.getFactory();

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.ReplicationMode;
@ -67,7 +65,7 @@ public class DefaultReplicateEventListener extends AbstractSaveEventListener imp
/*if ( persister.isUnsaved(entity, source) ) {
throw new TransientObjectException("transient instance passed to replicate()");
}*/
Serializable id = persister.getIdentifier( entity, source );
Object id = persister.getIdentifier( entity, source );
if ( id == null ) {
throw new TransientObjectException( "instance with null id passed to replicate()" );
}
@ -144,7 +142,7 @@ public class DefaultReplicateEventListener extends AbstractSaveEventListener imp
@Override
protected boolean visitCollectionsBeforeSave(
Object entity,
Serializable id,
Object id,
Object[] values,
Type[] types,
EventSource source) {
@ -157,7 +155,7 @@ public class DefaultReplicateEventListener extends AbstractSaveEventListener imp
@Override
protected boolean substituteValuesIfNecessary(
Object entity,
Serializable id,
Object id,
Object[] values,
EntityPersister persister,
SessionImplementor source) {
@ -171,7 +169,7 @@ public class DefaultReplicateEventListener extends AbstractSaveEventListener imp
private void performReplication(
Object entity,
Serializable id,
Object id,
Object version,
EntityPersister persister,
ReplicationMode replicationMode,

View File

@ -6,11 +6,9 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;
import org.hibernate.HibernateException;
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.spi.EventSource;
@ -40,7 +38,7 @@ public class DefaultResolveNaturalIdEventListener
@Override
public void onResolveNaturalId(ResolveNaturalIdEvent event) throws HibernateException {
final Serializable entityId = resolveNaturalId( event );
final Object entityId = resolveNaturalId( event );
event.setEntityId( entityId );
}
@ -54,7 +52,7 @@ public class DefaultResolveNaturalIdEventListener
*
* @return The loaded entity, or null.
*/
protected Serializable resolveNaturalId(final ResolveNaturalIdEvent event) {
protected Object resolveNaturalId(final ResolveNaturalIdEvent event) {
final EntityPersister persister = event.getEntityPersister();
if ( LOG.isTraceEnabled() ) {
@ -65,7 +63,7 @@ public class DefaultResolveNaturalIdEventListener
);
}
Serializable entityId = resolveFromCache( event );
Object entityId = resolveFromCache( event );
if ( entityId != null ) {
if ( LOG.isTraceEnabled() ) {
LOG.tracev(
@ -95,7 +93,7 @@ public class DefaultResolveNaturalIdEventListener
*
* @return The entity from the cache, or null.
*/
protected Serializable resolveFromCache(final ResolveNaturalIdEvent event) {
protected Object resolveFromCache(final ResolveNaturalIdEvent event) {
return event.getSession().getPersistenceContextInternal().getNaturalIdHelper().findCachedNaturalIdResolution(
event.getEntityPersister(),
event.getOrderedNaturalIdValues()
@ -110,7 +108,7 @@ public class DefaultResolveNaturalIdEventListener
*
* @return The object loaded from the datasource, or null if not found.
*/
protected Serializable loadFromDatasource(final ResolveNaturalIdEvent event) {
protected Object loadFromDatasource(final ResolveNaturalIdEvent event) {
final EventSource session = event.getSession();
final SessionFactoryImplementor factory = session.getFactory();
final StatisticsImplementor statistics = factory.getStatistics();
@ -120,7 +118,7 @@ public class DefaultResolveNaturalIdEventListener
startTime = System.nanoTime();
}
final Serializable pk = event.getEntityPersister().loadEntityIdByNaturalId(
final Object pk = event.getEntityPersister().loadEntityIdByNaturalId(
event.getOrderedNaturalIdValues(),
event.getLockOptions(),
session

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.Hibernate;
import org.hibernate.PersistentObjectException;
import org.hibernate.engine.spi.EntityEntry;
@ -21,7 +19,7 @@ import org.hibernate.event.spi.SaveOrUpdateEvent;
*/
public class DefaultSaveEventListener extends DefaultSaveOrUpdateEventListener {
protected Serializable performSaveOrUpdate(SaveOrUpdateEvent event) {
protected Object performSaveOrUpdate(SaveOrUpdateEvent event) {
// this implementation is supposed to tolerate incorrect unsaved-value
// mappings, for the purpose of backward-compatibility
EntityEntry entry = event.getSession().getPersistenceContextInternal().getEntry( event.getEntity() );
@ -33,7 +31,7 @@ public class DefaultSaveEventListener extends DefaultSaveOrUpdateEventListener {
}
}
protected Serializable saveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) {
protected Object saveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) {
if ( event.getRequestedId() == null ) {
return super.saveWithGeneratedOrRequestedId(event);
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
@ -51,7 +49,7 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
public void onSaveOrUpdate(SaveOrUpdateEvent event) {
final SessionImplementor source = event.getSession();
final Object object = event.getObject();
final Serializable requestedId = event.getRequestedId();
final Object requestedId = event.getRequestedId();
if ( requestedId != null ) {
//assign the requested id to the proxy, *before*
@ -81,7 +79,7 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
return source.getPersistenceContextInternal().reassociateIfUninitializedProxy( object );
}
protected Serializable performSaveOrUpdate(SaveOrUpdateEvent event) {
protected Object performSaveOrUpdate(SaveOrUpdateEvent event) {
EntityState entityState = getEntityState(
event.getEntity(),
event.getEntityName(),
@ -100,7 +98,7 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
}
}
protected Serializable entityIsPersistent(SaveOrUpdateEvent event) throws HibernateException {
protected Object entityIsPersistent(SaveOrUpdateEvent event) throws HibernateException {
if ( LOG.isTraceEnabled() ) {
LOG.trace( "Ignoring persistent instance" );
}
@ -116,9 +114,9 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
final SessionFactoryImplementor factory = event.getSession().getFactory();
Serializable requestedId = event.getRequestedId();
Object requestedId = event.getRequestedId();
Serializable savedId;
Object savedId;
if ( requestedId == null ) {
savedId = entityEntry.getId();
}
@ -159,7 +157,7 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
*
* @return The entity's identifier after saving.
*/
protected Serializable entityIsTransient(SaveOrUpdateEvent event) {
protected Object entityIsTransient(SaveOrUpdateEvent event) {
LOG.trace( "Saving transient instance" );
@ -175,7 +173,7 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
}
}
Serializable id = saveWithGeneratedOrRequestedId( event );
Object id = saveWithGeneratedOrRequestedId( event );
source.getPersistenceContextInternal().reassociateProxy( event.getObject(), id );
@ -189,7 +187,7 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
*
* @return The entity's identifier value after saving.
*/
protected Serializable saveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) {
protected Object saveWithGeneratedOrRequestedId(SaveOrUpdateEvent event) {
return saveWithGeneratedId(
event.getEntity(),
event.getEntityName(),
@ -242,13 +240,13 @@ public class DefaultSaveOrUpdateEventListener extends AbstractSaveEventListener
*
* @throws TransientObjectException If the entity is considered transient.
*/
protected Serializable getUpdateId(
protected Object getUpdateId(
Object entity,
EntityPersister persister,
Serializable requestedId,
Object requestedId,
SessionImplementor session) {
// use the id assigned to the instance
Serializable id = persister.getIdentifier( entity, session );
Object id = persister.getIdentifier( entity, session );
if ( id == null ) {
// assume this is a newly instantiated transient object
// which should be saved rather than updated

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.ObjectDeletedException;
import org.hibernate.engine.spi.EntityEntry;
@ -22,7 +20,7 @@ import org.hibernate.persister.entity.EntityPersister;
*/
public class DefaultUpdateEventListener extends DefaultSaveOrUpdateEventListener {
protected Serializable performSaveOrUpdate(SaveOrUpdateEvent event) {
protected Object performSaveOrUpdate(SaveOrUpdateEvent event) {
// this implementation is supposed to tolerate incorrect unsaved-value
// mappings, for the purpose of backward-compatibility
EntityEntry entry = event.getSession().getPersistenceContextInternal().getEntry( event.getEntity() );
@ -43,11 +41,12 @@ public class DefaultUpdateEventListener extends DefaultSaveOrUpdateEventListener
/**
* If the user specified an id, assign it to the instance and use that,
* otherwise use the id already assigned to the instance
* @return
*/
protected Serializable getUpdateId(
protected Object getUpdateId(
Object entity,
EntityPersister persister,
Serializable requestedId,
Object requestedId,
SessionImplementor session) throws HibernateException {
if ( requestedId == null ) {
return super.getUpdateId( entity, persister, requestedId, session );

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.spi.SessionImplementor;
@ -26,7 +24,7 @@ import org.hibernate.type.CollectionType;
*/
public class OnLockVisitor extends ReattachVisitor {
public OnLockVisitor(EventSource session, Serializable key, Object owner) {
public OnLockVisitor(EventSource session, Object key, Object owner) {
super( session, key, owner );
}
@ -42,7 +40,7 @@ public class OnLockVisitor extends ReattachVisitor {
if ( collection instanceof PersistentCollection ) {
final PersistentCollection persistentCollection = (PersistentCollection) collection;
if ( persistentCollection.setCurrentSession( session ) ) {
if ( isOwnerUnchanged( persistentCollection, persister, extractCollectionKeyFromOwner( persister ) ) ) {
if ( isOwnerUnchanged( persister, extractCollectionKeyFromOwner( persister ), persistentCollection ) ) {
// a "detached" collection that originally belonged to the same entity
if ( persistentCollection.isDirty() ) {
throw new HibernateException( "reassociated object has dirty collection" );

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.spi.SessionImplementor;
@ -30,7 +28,7 @@ public class OnReplicateVisitor extends ReattachVisitor {
private boolean isUpdate;
OnReplicateVisitor(EventSource session, Serializable key, Object owner, boolean isUpdate) {
OnReplicateVisitor(EventSource session, Object key, Object owner, boolean isUpdate) {
super( session, key, owner );
this.isUpdate = isUpdate;
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.event.spi.EventSource;
@ -26,7 +24,7 @@ import org.hibernate.type.CollectionType;
*/
public class OnUpdateVisitor extends ReattachVisitor {
OnUpdateVisitor(EventSource session, Serializable key, Object owner) {
OnUpdateVisitor(EventSource session, Object key, Object owner) {
super( session, key, owner );
}
@ -40,12 +38,12 @@ public class OnUpdateVisitor extends ReattachVisitor {
EventSource session = getSession();
CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
final Serializable collectionKey = extractCollectionKeyFromOwner( persister );
if ( collection!=null && (collection instanceof PersistentCollection) ) {
final Object collectionKey = extractCollectionKeyFromOwner( persister );
if ( ( collection instanceof PersistentCollection ) ) {
PersistentCollection wrapper = (PersistentCollection) collection;
if ( wrapper.setCurrentSession(session) ) {
//a "detached" collection!
if ( !isOwnerUnchanged( wrapper, persister, collectionKey ) ) {
if ( !isOwnerUnchanged( persister, collectionKey, wrapper ) ) {
// if the collection belonged to a different entity,
// clean up the existing state of the collection
removeCollection( persister, collectionKey, session );

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.event.spi.EventSource;
@ -42,9 +40,7 @@ public abstract class ProxyVisitor extends AbstractVisitor {
* was snapshotted and detached?
*/
protected static boolean isOwnerUnchanged(
final PersistentCollection snapshot,
final CollectionPersister persister,
final Serializable id
final CollectionPersister persister, final Object id, final PersistentCollection snapshot
) {
return isCollectionSnapshotValid(snapshot) &&
persister.getRole().equals( snapshot.getRole() ) &&

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException;
import org.hibernate.action.internal.CollectionRemoveAction;
import org.hibernate.event.spi.EventSource;
@ -26,10 +24,10 @@ import org.hibernate.type.Type;
public abstract class ReattachVisitor extends ProxyVisitor {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( ReattachVisitor.class );
private final Serializable ownerIdentifier;
private final Object ownerIdentifier;
private final Object owner;
public ReattachVisitor(EventSource session, Serializable ownerIdentifier, Object owner) {
public ReattachVisitor(EventSource session, Object ownerIdentifier, Object owner) {
super( session );
this.ownerIdentifier = ownerIdentifier;
this.owner = owner;
@ -40,7 +38,7 @@ public abstract class ReattachVisitor extends ProxyVisitor {
*
* @return The entity's identifier.
*/
final Serializable getOwnerIdentifier() {
final Object getOwnerIdentifier() {
return ownerIdentifier;
}
@ -78,7 +76,7 @@ public abstract class ReattachVisitor extends ProxyVisitor {
*
* @throws HibernateException
*/
void removeCollection(CollectionPersister role, Serializable collectionKey, EventSource source)
void removeCollection(CollectionPersister role, Object collectionKey, EventSource source)
throws HibernateException {
if ( LOG.isTraceEnabled() ) {
LOG.tracev(
@ -99,11 +97,11 @@ public abstract class ReattachVisitor extends ProxyVisitor {
*
* @return The value from the owner that identifies the grouping into the collection
*/
final Serializable extractCollectionKeyFromOwner(CollectionPersister role) {
final Object extractCollectionKeyFromOwner(CollectionPersister role) {
if ( role.getCollectionType().useLHSPrimaryKey() ) {
return ownerIdentifier;
}
return (Serializable) role.getOwnerEntityPersister().getPropertyValue(
return role.getOwnerEntityPersister().getPropertyValue(
owner,
role.getCollectionType().getLHSPropertyName()
);

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
@ -32,11 +30,11 @@ import org.hibernate.type.Type;
public class WrapVisitor extends ProxyVisitor {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( WrapVisitor.class );
private Object entity;
private Serializable id;
private Object id;
private boolean substitute;
public WrapVisitor(Object entity, Serializable id, EventSource session) {
public WrapVisitor(Object entity, Object id, EventSource session) {
super( session );
this.entity = entity;
this.id = id;

View File

@ -22,26 +22,25 @@ public abstract class AbstractCollectionEvent extends AbstractEvent {
private final PersistentCollection collection;
private final Object affectedOwner;
private final Serializable affectedOwnerId;
private final Object affectedOwnerId;
private final String affectedOwnerEntityName;
/**
* Constructs an AbstractCollectionEvent object.
*
* @param collection - the collection
* @param collection - the collection
* @param source - the Session source
* @param affectedOwner - the owner that is affected by this event;
* can be null if unavailable
* can be null if unavailable
* @param affectedOwnerId - the ID for the owner that is affected
* by this event; can be null if unavailable
* that is affected by this event; can be null if unavailable
* by this event; can be null if unavailable
*/
public AbstractCollectionEvent( CollectionPersister collectionPersister,
PersistentCollection collection,
EventSource source,
Object affectedOwner,
Serializable affectedOwnerId) {
super(source);
public AbstractCollectionEvent(
CollectionPersister collectionPersister,
PersistentCollection collection,
EventSource source,
Object affectedOwner,
Object affectedOwnerId) {
super( source );
this.collection = collection;
this.affectedOwner = affectedOwner;
this.affectedOwnerId = affectedOwnerId;
@ -58,11 +57,11 @@ public abstract class AbstractCollectionEvent extends AbstractEvent {
return source.getPersistenceContextInternal().getLoadedCollectionOwnerOrNull( collection );
}
protected static Serializable getLoadedOwnerIdOrNull( PersistentCollection collection, EventSource source ) {
protected static Object getLoadedOwnerIdOrNull(PersistentCollection collection, EventSource source ) {
return source.getPersistenceContextInternal().getLoadedCollectionOwnerIdOrNull( collection );
}
protected static Serializable getOwnerIdOrNull( Object owner, EventSource source ) {
protected static Object getOwnerIdOrNull(Object owner, EventSource source ) {
EntityEntry ownerEntry = source.getPersistenceContextInternal().getEntry( owner );
return ( ownerEntry == null ? null : ownerEntry.getId() );
}
@ -103,7 +102,7 @@ public abstract class AbstractCollectionEvent extends AbstractEvent {
* from the collection's loaded key (e.g., a property-ref is used for the
* collection and does not include the entity's ID)
*/
public Serializable getAffectedOwnerIdOrNull() {
public Object getAffectedOwnerIdOrNull() {
return affectedOwnerId;
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.spi;
import java.io.Serializable;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.secure.spi.PermissionCheckEntityInformation;
@ -21,13 +19,12 @@ public abstract class AbstractPreDatabaseOperationEvent
implements PermissionCheckEntityInformation {
private final Object entity;
private final Serializable id;
private final Object id;
private final EntityPersister persister;
/**
* Constructs an event containing the pertinent information.
*
* @param source The session from which the event originated.
* @param source The session from which the event originated.
* @param entity The entity to be invloved in the database operation.
* @param id The entity id to be invloved in the database operation.
* @param persister The entity's persister.
@ -35,7 +32,7 @@ public abstract class AbstractPreDatabaseOperationEvent
public AbstractPreDatabaseOperationEvent(
EventSource source,
Object entity,
Serializable id,
Object id,
EntityPersister persister) {
super( source );
this.entity = entity;
@ -58,7 +55,7 @@ public abstract class AbstractPreDatabaseOperationEvent
*
* @return The id.
*/
public Serializable getId() {
public Object getId() {
return id;
}
@ -94,7 +91,7 @@ public abstract class AbstractPreDatabaseOperationEvent
}
@Override
public Serializable getIdentifier() {
public Object getIdentifier() {
return id;
}
}

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.event.spi;
import java.io.Serializable;
import java.util.Map;
import java.util.Set;
@ -30,7 +29,7 @@ public interface EventSource extends SessionImplementor {
* Instantiate an entity instance, using either an interceptor,
* or the given persister
*/
Object instantiate(EntityPersister persister, Serializable id) throws HibernateException;
Object instantiate(EntityPersister persister, Object id) throws HibernateException;
/**
* Force an immediate flush

View File

@ -16,10 +16,12 @@ import org.hibernate.collection.spi.PersistentCollection;
*/
public class InitializeCollectionEvent extends AbstractCollectionEvent {
public InitializeCollectionEvent(PersistentCollection collection, EventSource source ) {
super( getLoadedCollectionPersister( collection, source ),
super(
getLoadedCollectionPersister( collection, source ),
collection,
source,
getLoadedOwnerOrNull( collection, source ),
getLoadedOwnerIdOrNull( collection, source ) );
getLoadedOwnerIdOrNull( collection, source )
);
}
}

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.event.spi;
import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
@ -39,7 +37,7 @@ public class LoadEvent extends AbstractEvent {
}
};
private Serializable entityId;
private Object entityId;
private String entityClassName;
private Object instanceToLoad;
private LockOptions lockOptions;
@ -47,40 +45,41 @@ public class LoadEvent extends AbstractEvent {
private Object result;
private PostLoadEvent postLoadEvent;
public LoadEvent(Serializable entityId, Object instanceToLoad, EventSource source) {
public LoadEvent(Object entityId, Object instanceToLoad, EventSource source) {
this( entityId, null, instanceToLoad, DEFAULT_LOCK_OPTIONS, false, source );
}
public LoadEvent(Serializable entityId, String entityClassName, LockMode lockMode, EventSource source) {
public LoadEvent(Object entityId, String entityClassName, LockMode lockMode, EventSource source) {
this( entityId, entityClassName, null, lockMode, false, source );
}
public LoadEvent(Serializable entityId, String entityClassName, LockOptions lockOptions, EventSource source) {
public LoadEvent(Object entityId, String entityClassName, LockOptions lockOptions, EventSource source) {
this( entityId, entityClassName, null, lockOptions, false, source );
}
public LoadEvent(Serializable entityId, String entityClassName, boolean isAssociationFetch, EventSource source) {
public LoadEvent(Object entityId, String entityClassName, boolean isAssociationFetch, EventSource source) {
this( entityId, entityClassName, null, DEFAULT_LOCK_OPTIONS, isAssociationFetch, source );
}
public boolean isAssociationFetch() {
return isAssociationFetch;
}
private LoadEvent(
Serializable entityId,
Object entityId,
String entityClassName,
Object instanceToLoad,
LockMode lockMode,
boolean isAssociationFetch,
EventSource source) {
this( entityId, entityClassName, instanceToLoad,
this(
entityId,
entityClassName,
instanceToLoad,
lockMode == DEFAULT_LOCK_MODE ? DEFAULT_LOCK_OPTIONS : new LockOptions().setLockMode( lockMode ),
isAssociationFetch, source );
isAssociationFetch,
source
);
}
private LoadEvent(
Serializable entityId,
Object entityId,
String entityClassName,
Object instanceToLoad,
LockOptions lockOptions,
@ -108,11 +107,11 @@ public class LoadEvent extends AbstractEvent {
this.postLoadEvent = new PostLoadEvent( source );
}
public Serializable getEntityId() {
public Object getEntityId() {
return entityId;
}
public void setEntityId(Serializable entityId) {
public void setEntityId(Object entityId) {
this.entityId = entityId;
}
@ -124,6 +123,10 @@ public class LoadEvent extends AbstractEvent {
this.entityClassName = entityClassName;
}
public boolean isAssociationFetch() {
return isAssociationFetch;
}
public Object getInstanceToLoad() {
return instanceToLoad;
}

Some files were not shown because too many files have changed in this diff Show More