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

View File

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

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate; package org.hibernate;
import java.io.Serializable;
/** /**
* Thrown when the user tries to do something illegal with a deleted object. * 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 { public class ObjectDeletedException extends UnresolvableObjectException {
/** /**
* Constructs an ObjectDeletedException using the given information. * 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 identifier The identifier of the entity
* @param entityName The name 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 ); super( message, identifier, entityName );
} }

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate; package org.hibernate;
import java.io.Serializable;
/** /**
* Thrown when <tt>Session.load()</tt> fails to select a row with * Thrown when <tt>Session.load()</tt> fails to select a row with
* the given primary key (identifier value). This exception might not * the given primary key (identifier value). This exception might not
@ -24,11 +22,14 @@ import java.io.Serializable;
public class ObjectNotFoundException extends UnresolvableObjectException { public class ObjectNotFoundException extends UnresolvableObjectException {
/** /**
* Constructs a ObjectNotFoundException using the given information. * 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 * @param entityName The name of the entity
*/ */
public ObjectNotFoundException(Serializable identifier, String entityName) { public ObjectNotFoundException(Object identifier, String entityName) {
super( identifier, 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.graph.RootGraph;
import org.hibernate.jdbc.ReturningWork; import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.Work; import org.hibernate.jdbc.Work;
import org.hibernate.jpa.HibernateEntityManager;
import org.hibernate.stat.SessionStatistics; 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 * To override this session's read-only/modifiable setting for entities
* and proxies loaded by a Query: * 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; * @param readOnly true, the default for loaded entities/proxies is read-only;
* false, the default for loaded entities/proxies is modifiable * 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 * @throws TransientObjectException if the instance is transient or associated with
* a different session * a different session
*/ */
Serializable getIdentifier(Object object); Object getIdentifier(Object object);
/** /**
* Check if this entity is associated with this Session. This form caters to * 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, * Return the persistent instance of the given entity class with the given identifier,
* obtaining the specified lock mode, assuming the instance exists. * obtaining the specified lock mode, assuming the instance exists.
* <p/> * <p/>
* Convenient form of {@link #load(Class, Serializable, LockOptions)} * Convenient form of {@link #load(Class, Object, LockOptions)}
* *
* @param theClass a persistent class * @param theClass a persistent class
* @param id a valid identifier of an existing persistent instance of the 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 * @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, * 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 * @param lockOptions contains the lock level
* @return the persistent instance or proxy * @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, * Return the persistent instance of the given entity class with the given identifier,
* obtaining the specified lock mode, assuming the instance exists. * obtaining the specified lock mode, assuming the instance exists.
* <p/> * <p/>
* Convenient form of {@link #load(String, Serializable, LockOptions)} * Convenient form of {@link #load(String, Object, LockOptions)}
* *
* @param entityName a persistent class * @param entityName a persistent class
* @param id a valid identifier of an existing persistent instance of the 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 * @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, * 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 * @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, * 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 * @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, * 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 * @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 * Read the persistent state associated with the given identifier into the given transient
* instance. * 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 * 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 * @return the generated identifier
*/ */
Serializable save(Object object); Object save(Object object);
/** /**
* Persist the given transient instance, first assigning a generated identifier. (Or * 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 * @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 * 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 * @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, * 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.) * with the session, return that instance. This method never returns an uninitialized instance.)
* Obtain the specified lock mode if the instance exists. * Obtain the specified lock mode if the instance exists.
* <p/> * <p/>
* Convenient form of {@link #get(Class, Serializable, LockOptions)} * Convenient form of {@link #get(Class, Object, LockOptions)}
* *
* @param entityType The entity type * @param entityType The entity type
* @param id an identifier * @param id an identifier
@ -709,9 +705,9 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
* *
* @return a persistent instance or null * @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, * 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 * @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, * 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 * @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, * 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.) * with the session, return that instance. This method never returns an uninitialized instance.)
* Obtain the specified lock mode if the instance exists. * Obtain the specified lock mode if the instance exists.
* <p/> * <p/>
* Convenient form of {@link #get(String, Serializable, LockOptions)} * Convenient form of {@link #get(String, Object, LockOptions)}
* *
* @param entityName the entity name * @param entityName the entity name
* @param id an identifier * @param id an identifier
@ -753,7 +749,7 @@ public interface Session extends SharedSessionContract, EntityManager, AutoClose
* *
* @return a persistent instance or null * @return a persistent instance or null
* *
* @see #get(String, Serializable, LockOptions) * @see #get(String, Object, LockOptions)
*/ */
Object get(String entityName, Serializable id, LockMode lockMode); 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 * @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. * 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 * To override this session's read-only/modifiable setting for entities
* and proxies loaded by a Query: * and proxies loaded by a Query:
* @see Query#setReadOnly(boolean) * @see org.hibernate.query.Query#setReadOnly(boolean)
* *
* @param entityOrProxy an entity or HibernateProxy * @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 * @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; package org.hibernate;
import java.io.Serializable;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
/** /**
@ -18,15 +16,14 @@ import org.hibernate.pretty.MessageHelper;
*/ */
public class StaleObjectStateException extends StaleStateException { public class StaleObjectStateException extends StaleStateException {
private final String entityName; private final String entityName;
private final Serializable identifier; private final Object identifier;
/** /**
* Constructs a StaleObjectStateException using the supplied information. * 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 * @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)" ); super( "Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)" );
this.entityName = entityName; this.entityName = entityName;
this.identifier = identifier; this.identifier = identifier;
@ -36,7 +33,7 @@ public class StaleObjectStateException extends StaleStateException {
return entityName; return entityName;
} }
public Serializable getIdentifier() { public Object getIdentifier() {
return identifier; return identifier;
} }

View File

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

View File

@ -17,20 +17,19 @@ import org.hibernate.pretty.MessageHelper;
* @author Gavin King * @author Gavin King
*/ */
public class UnresolvableObjectException extends HibernateException { public class UnresolvableObjectException extends HibernateException {
private final Serializable identifier; private final Object identifier;
private final String entityName; private final String entityName;
/** /**
* Constructs an UnresolvableObjectException using the specified information. * 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 * @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 ); 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 ); super( message );
this.identifier = identifier; this.identifier = identifier;
this.entityName = clazz; this.entityName = clazz;
@ -45,14 +44,14 @@ public class UnresolvableObjectException extends HibernateException {
* *
* @throws UnresolvableObjectException Thrown if entity is null * @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 { throws UnresolvableObjectException {
if ( entity == null ) { if ( entity == null ) {
throw new UnresolvableObjectException( identifier, entityName ); throw new UnresolvableObjectException( identifier, entityName );
} }
} }
public Serializable getIdentifier() { public Object getIdentifier() {
return identifier; return identifier;
} }

View File

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

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.action.internal; package org.hibernate.action.internal;
import java.io.Serializable;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.engine.internal.ForeignKeys; import org.hibernate.engine.internal.ForeignKeys;
import org.hibernate.engine.internal.NonNullableTransientDependencies; import org.hibernate.engine.internal.NonNullableTransientDependencies;
@ -34,17 +32,16 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
/** /**
* Constructs an AbstractEntityInsertAction object. * Constructs an AbstractEntityInsertAction object.
* * @param id - the entity ID
* @param id - the entity ID
* @param state - the entity state * @param state - the entity state
* @param instance - the entity * @param instance - the entity
* @param isVersionIncrementDisabled - true, if version increment should * @param isVersionIncrementDisabled - true, if version increment should
* be disabled; false, otherwise * be disabled; false, otherwise
* @param persister - the entity persister * @param persister - the entity persister
* @param session - the session * @param session - the session
*/ */
protected AbstractEntityInsertAction( protected AbstractEntityInsertAction(
Serializable id, Object id,
Object[] state, Object[] state,
Object instance, Object instance,
boolean isVersionIncrementDisabled, boolean isVersionIncrementDisabled,
@ -180,7 +177,7 @@ public abstract class AbstractEntityInsertAction extends EntityAction {
* *
* @param generatedId The generated entity identifier * @param generatedId The generated entity identifier
*/ */
public void handleNaturalIdPostSaveNotifications(Serializable generatedId) { public void handleNaturalIdPostSaveNotifications(Object generatedId) {
final PersistenceContext.NaturalIdHelper naturalIdHelper = getSession().getPersistenceContextInternal().getNaturalIdHelper(); final PersistenceContext.NaturalIdHelper naturalIdHelper = getSession().getPersistenceContextInternal().getNaturalIdHelper();
if ( isEarlyInsert() ) { if ( isEarlyInsert() ) {
// with early insert, we still need to add a local (transactional) natural id cross-reference // 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 transient SharedSessionContractImplementor session;
private final PersistentCollection collection; private final PersistentCollection collection;
private final Serializable key; private final Object key;
private final String collectionRole; private final String collectionRole;
protected CollectionAction( protected CollectionAction(
final CollectionPersister persister, final CollectionPersister persister,
final PersistentCollection collection, final PersistentCollection collection,
final Serializable key, final Object key,
final SharedSessionContractImplementor session) { final SharedSessionContractImplementor session) {
this.persister = persister; this.persister = persister;
this.session = session; this.session = session;
@ -110,8 +110,8 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
return persister; return persister;
} }
protected final Serializable getKey() { protected final Object getKey() {
Serializable finalKey = key; Object finalKey = key;
if ( key instanceof DelayedPostInsertIdentifier ) { if ( key instanceof DelayedPostInsertIdentifier ) {
// need to look it up from the persistence-context // need to look it up from the persistence-context
finalKey = session.getPersistenceContextInternal().getEntry( collection.getOwner() ).getId(); 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 static class CacheCleanupProcess implements AfterTransactionCompletionProcess {
private final Serializable key; private final Object key;
private final CollectionPersister persister; private final CollectionPersister persister;
private final SoftLock lock; private final SoftLock lock;
private CacheCleanupProcess(Serializable key, CollectionPersister persister, SoftLock lock) { private CacheCleanupProcess(Object key, CollectionPersister persister, SoftLock lock) {
this.key = key; this.key = key;
this.persister = persister; this.persister = persister;
this.lock = lock; this.lock = lock;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,6 @@
package org.hibernate.bytecode.enhance.spi.interceptor; package org.hibernate.bytecode.enhance.spi.interceptor;
import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -79,7 +78,7 @@ public class LazyAttributeLoadingInterceptor extends AbstractLazyLoadInterceptor
final EntityPersister persister = session.getFactory().getMetamodel().entityPersister( getEntityName() ); final EntityPersister persister = session.getFactory().getMetamodel().entityPersister( getEntityName() );
if ( isTemporarySession ) { 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 // 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... // NOTE : a few arguments that would be nice to pass along here...

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -251,7 +251,7 @@ public class PersistentArrayHolder extends AbstractPersistentCollection {
} }
@Override @Override
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner)
throws HibernateException { throws HibernateException {
final Serializable[] cached = (Serializable[]) disassembled; final Serializable[] cached = (Serializable[]) disassembled;
array = Array.newInstance( persister.getElementClass(), cached.length ); array = Array.newInstance( persister.getElementClass(), cached.length );
@ -262,9 +262,9 @@ public class PersistentArrayHolder extends AbstractPersistentCollection {
} }
@Override @Override
public Serializable disassemble(CollectionPersister persister) throws HibernateException { public Object disassemble(CollectionPersister persister) throws HibernateException {
final int length = Array.getLength( array ); 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++ ) { for ( int i=0; i<length; i++ ) {
result[i] = persister.getElementType().disassemble( Array.get( array,i ), getSession(), null ); 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 @Override
public Serializable disassemble(CollectionPersister persister) public Object disassemble(CollectionPersister persister) {
throws HibernateException {
final int length = bag.size(); final int length = bag.size();
final Serializable[] result = new Serializable[length]; final Object[] result = new Object[length];
for ( int i=0; i<length; i++ ) { for ( int i=0; i<length; i++ ) {
result[i] = persister.getElementType().disassemble( bag.get( i ), getSession(), null ); result[i] = persister.getElementType().disassemble( bag.get( i ), getSession(), null );
} }
@ -273,7 +272,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner) public void initializeFromCache(CollectionPersister persister, Object disassembled, Object owner)
throws HibernateException { throws HibernateException {
final Serializable[] array = (Serializable[]) disassembled; final Serializable[] array = (Serializable[]) disassembled;
final int size = array.length; final int size = array.length;

View File

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

View File

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

View File

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

View File

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

View File

@ -73,12 +73,11 @@ public interface PersistentCollection {
/** /**
* After flushing, re-init snapshot state. * 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 role The collection role
* @param snapshot The snapshot state * @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 * 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 * 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 disassembled The disassembled cached state
* @param owner The collection owner * @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 * Iterate all collection entries, during update of the database
@ -260,7 +258,7 @@ public interface PersistentCollection {
* *
* @return The disassembled state * @return The disassembled state
*/ */
Serializable disassemble(CollectionPersister persister) ; Object disassemble(CollectionPersister persister) ;
/** /**
* Do we need to completely recreate this collection when it changes? * Do we need to completely recreate this collection when it changes?
@ -379,7 +377,7 @@ public interface PersistentCollection {
* *
* @return the current collection key value * @return the current collection key value
*/ */
Serializable getKey(); Object getKey();
/** /**
* Get the current role name * Get the current role name

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.io.Serializable;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
@ -624,7 +623,7 @@ public class HSQLDialect extends Dialect {
} }
@Override @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 { throws StaleObjectStateException, JDBCException {
if ( getLockMode().greaterThan( LockMode.READ ) ) { if ( getLockMode().greaterThan( LockMode.READ ) ) {
LOG.hsqldbSupportsOnlyReadCommittedIsolation(); LOG.hsqldbSupportsOnlyReadCommittedIsolation();

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.dialect.lock; package org.hibernate.dialect.lock;
import java.io.Serializable;
import org.hibernate.StaleObjectStateException; import org.hibernate.StaleObjectStateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
@ -39,6 +37,6 @@ public interface LockingStrategy {
* the requested lock. * the requested lock.
* @throws LockingStrategyException Indicates a failure in the lock attempt * @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; throws StaleObjectStateException, LockingStrategyException;
} }

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.dialect.lock; package org.hibernate.dialect.lock;
import java.io.Serializable;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.action.internal.EntityIncrementVersionProcess; import org.hibernate.action.internal.EntityIncrementVersionProcess;
@ -44,7 +42,7 @@ public class OptimisticForceIncrementLockingStrategy implements LockingStrategy
} }
@Override @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() ) { if ( !lockable.isVersioned() ) {
throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
} }

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.dialect.lock; package org.hibernate.dialect.lock;
import java.io.Serializable;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.OptimisticLockException; import org.hibernate.OptimisticLockException;
@ -44,7 +42,7 @@ public class OptimisticLockingStrategy implements LockingStrategy {
} }
@Override @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() ) { if ( !lockable.isVersioned() ) {
throw new OptimisticLockException( object, "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); throw new OptimisticLockException( object, "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
} }

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.dialect.lock; package org.hibernate.dialect.lock;
import java.io.Serializable;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.EntityEntry;
@ -43,7 +41,7 @@ public class PessimisticForceIncrementLockingStrategy implements LockingStrategy
} }
@Override @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() ) { if ( !lockable.isVersioned() ) {
throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
} }

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.dialect.lock; package org.hibernate.dialect.lock;
import java.io.Serializable;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -53,7 +52,7 @@ public class PessimisticReadSelectLockingStrategy extends AbstractSelectLockingS
} }
@Override @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 String sql = determineSql( timeout );
final SessionFactoryImplementor factory = session.getFactory(); final SessionFactoryImplementor factory = session.getFactory();
try { try {

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.dialect.lock; package org.hibernate.dialect.lock;
import java.io.Serializable;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
@ -69,7 +68,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy {
} }
@Override @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() ) { if ( !lockable.isVersioned() ) {
throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" ); 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; package org.hibernate.dialect.lock;
import java.io.Serializable;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -52,7 +51,7 @@ public class PessimisticWriteSelectLockingStrategy extends AbstractSelectLocking
} }
@Override @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 String sql = determineSql( timeout );
final SessionFactoryImplementor factory = session.getFactory(); final SessionFactoryImplementor factory = session.getFactory();
try { try {

View File

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

View File

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

View File

@ -9,11 +9,9 @@ package org.hibernate.engine.internal;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.function.Supplier;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.CustomEntityDirtinessStrategy; import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.Session; import org.hibernate.Session;
@ -43,7 +41,7 @@ import org.hibernate.pretty.MessageHelper;
* @author Sanne Grinovero <sanne@hibernate.org> * @author Sanne Grinovero <sanne@hibernate.org>
*/ */
public abstract class AbstractEntityEntry implements Serializable, EntityEntry { public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
protected final Serializable id; protected final Object id;
protected Object[] loadedState; protected Object[] loadedState;
protected Object version; protected Object version;
protected final EntityPersister persister; // permanent but we only need the entityName state in a non transient way 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; 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( public AbstractEntityEntry(
final Status status, final Status status,
final Object[] loadedState, final Object[] loadedState,
final Object rowId, final Object rowId,
final Serializable id, final Object 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 version, final Object version,
final LockMode lockMode, final LockMode lockMode,
final boolean existsInDatabase, final boolean existsInDatabase,
@ -196,7 +171,7 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
} }
@Override @Override
public Serializable getId() { public Object getId() {
return id; 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.EntityKey;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.jboss.logging.Logger; 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 * Remove the entity key with the specified {@code id} and {@code persister} from
* the batch loadable entities {@link BatchFetchQueue}. * 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( public static void removeBatchLoadableEntityKey(
Serializable id, Object id,
EntityPersister persister, EntityPersister persister,
SharedSessionContractImplementor session) { SharedSessionContractImplementor session) {
final EntityKey entityKey = session.generateEntityKey( id, persister ); final EntityKey entityKey = session.generateEntityKey( id, persister );
final BatchFetchQueue batchFetchQueue = session.getPersistenceContextInternal().getBatchFetchQueue(); final BatchFetchQueue batchFetchQueue = session.getPersistenceContextInternal().getBatchFetchQueue();
batchFetchQueue.removeBatchLoadableEntityKey( entityKey ); 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; package org.hibernate.engine.internal;
import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -323,7 +322,7 @@ public final class Cascade {
if ( valueEntry != null ) { if ( valueEntry != null ) {
final String entityName = valueEntry.getPersister().getEntityName(); final String entityName = valueEntry.getPersister().getEntityName();
if ( LOG.isTraceEnabled() ) { 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 ); final String description = MessageHelper.infoString( entityName, id );
LOG.tracev( "Deleting orphaned entity instance: {0}", description ); LOG.tracev( "Deleting orphaned entity instance: {0}", description );
} }

View File

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

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.engine.internal; package org.hibernate.engine.internal;
import java.io.Serializable;
import org.hibernate.EntityMode; import org.hibernate.EntityMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.TransientObjectException; 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) * @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 String entityName,
final Object object, final Object object,
final SharedSessionContractImplementor session) throws TransientObjectException { final SharedSessionContractImplementor session) throws TransientObjectException {
@ -336,7 +334,7 @@ public final class ForeignKeys {
return null; return null;
} }
else { else {
Serializable id = session.getContextEntityIdentifier( object ); Object id = session.getContextEntityIdentifier( object );
if ( id == null ) { if ( id == null ) {
// context-entity-identifier returns null explicitly if the entity // context-entity-identifier returns null explicitly if the entity
// is not associated with the persistence context; so make some // 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 * @see org.hibernate.annotations.Immutable
*/ */
public final class ImmutableEntityEntry extends AbstractEntityEntry { 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( public ImmutableEntityEntry(
final Status status, final Status status,
final Object[] loadedState, final Object[] loadedState,
final Object rowId, final Object rowId,
final Serializable id, final Object 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 version, final Object version,
final LockMode lockMode, final LockMode lockMode,
final boolean existsInDatabase, final boolean existsInDatabase,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -122,7 +122,7 @@ public interface PersistenceContext {
* *
* @see #getCachedDatabaseSnapshot * @see #getCachedDatabaseSnapshot
*/ */
Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister); Object[] getDatabaseSnapshot(Object id, EntityPersister persister);
/** /**
* Retrieve the cached database snapshot for the requested entity key. * 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. * @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 * Add a canonical mapping from entity key to entity instance
@ -257,7 +257,7 @@ public interface PersistenceContext {
final Status status, final Status status,
final Object[] loadedState, final Object[] loadedState,
final Object rowId, final Object rowId,
final Serializable id, final Object id,
final Object version, final Object version,
final LockMode lockMode, final LockMode lockMode,
final boolean existsInDatabase, final boolean existsInDatabase,
@ -281,20 +281,20 @@ public interface PersistenceContext {
* @return Whether the passed value represented an actual proxy which got initialized. * @return Whether the passed value represented an actual proxy which got initialized.
* @throws MappingException * @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 * If a deleted entity instance is re-saved, and it has a proxy, we need to
* reset the identifier of the proxy * 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 * Get the entity instance underlying the given proxy, throwing
* an exception if the proxy is uninitialized. If the given object * an exception if the proxy is uninitialized. If the given object
* is not a proxy, simply return the argument. * 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. * Possibly unproxy the given reference and reassociate it with the current session.
@ -303,7 +303,7 @@ public interface PersistenceContext {
* @return The unproxied instance. * @return The unproxied instance.
* @throws HibernateException * @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 * Attempts to check whether the given key represents an entity already loaded within the
@ -313,7 +313,7 @@ public interface PersistenceContext {
* *
* @throws HibernateException * @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 * If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy
@ -328,23 +328,21 @@ public interface PersistenceContext {
* @return An appropriately narrowed instance. * @return An appropriately narrowed instance.
* @throws HibernateException * @throws HibernateException
*/ */
Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object) Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object);
throws HibernateException;
/** /**
* Return the existing proxy associated with the given <tt>EntityKey</tt>, or the * 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 * third argument (the entity associated with the key) if no proxy exists. Init
* the proxy to the target implementation, if necessary. * the proxy to the target implementation, if necessary.
*/ */
Object proxyFor(EntityPersister persister, EntityKey key, Object impl) Object proxyFor(EntityPersister persister, EntityKey key, Object impl);
throws HibernateException;
/** /**
* Return the existing proxy associated with the given <tt>EntityKey</tt>, or the * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
* argument (the entity associated with the key) if no proxy exists. * argument (the entity associated with the key) if no proxy exists.
* (slower than the form above) * (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)} * 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 * Get the entity that owns this persistent collection
*/ */
Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) Object getCollectionOwner(Object key, CollectionPersister collectionPersister);
throws MappingException;
/** /**
* Get the entity that owned this persistent collection when it was loaded * Get the entity that owned this persistent collection when it was loaded
@ -373,27 +370,24 @@ public interface PersistenceContext {
* @param collection The persistent collection * @param collection The persistent collection
* @return the owner ID if available from the collection's loaded key; otherwise, returns null * @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) * add a collection we just loaded up (still needs initializing)
*/ */
void addUninitializedCollection(CollectionPersister persister, void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Object id);
PersistentCollection collection, Serializable id);
/** /**
* add a detached uninitialized collection * add a detached uninitialized collection
*/ */
void addUninitializedDetachedCollection(CollectionPersister persister, void addUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection);
PersistentCollection collection);
/** /**
* Add a new collection (ie. a newly created one, just instantiated by the * Add a new collection (ie. a newly created one, just instantiated by the
* application, with no database state or snapshot) * application, with no database state or snapshot)
* @param collection The collection to be associated with the persistence context * @param collection The collection to be associated with the persistence context
*/ */
void addNewCollection(CollectionPersister persister, PersistentCollection collection) void addNewCollection(CollectionPersister persister, PersistentCollection collection);
throws HibernateException;
/** /**
* add an (initialized) collection that was created by another session and passed * add an (initialized) collection that was created by another session and passed
@ -409,7 +403,7 @@ public interface PersistenceContext {
CollectionEntry addInitializedCollection( CollectionEntry addInitializedCollection(
CollectionPersister persister, CollectionPersister persister,
PersistentCollection collection, PersistentCollection collection,
Serializable id); Object id);
/** /**
* Get the collection instance associated with the <tt>CollectionKey</tt> * 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 * @return The id of the entityName instance which is said to own the child; null if an appropriate owner not
* located. * 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, * 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 * To override this session's read-only/modifiable setting for entities
* and proxies loaded by a Query: * 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; * @param readOnly true, the default for loaded entities/proxies is read-only;
* false, the default for loaded entities/proxies is modifiable * 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#setDefaultReadOnly
* @see org.hibernate.Session#setReadOnly * @see org.hibernate.Session#setReadOnly
* @see org.hibernate.Query#setReadOnly * @see org.hibernate.query.Query#setReadOnly
*/ */
void setReadOnly(Object entityOrProxy, boolean readOnly); 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 * Add a child/parent relation to cache for cascading op
@ -724,11 +718,10 @@ public interface PersistenceContext {
/** /**
* Register keys inserted during the current transaction * Register keys inserted during the current transaction
* * @param persister The entity persister
* @param persister The entity persister
* @param id The id * @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. * 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. * @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}. * 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. * Performs processing related to creating natural-id cross-reference entries on load.
* Handles both the local (transactional) and shared (second-level) caches. * 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 id The primary key value
* @param naturalIdValues The natural id values * @param naturalIdValues The natural id values
*/ */
void cacheNaturalIdCrossReferenceFromLoad( void cacheNaturalIdCrossReferenceFromLoad(
EntityPersister persister, EntityPersister persister,
Serializable id, Object id,
Object[] naturalIdValues); Object[] naturalIdValues);
/** /**
* Creates necessary local cross-reference entries. * 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 id The primary key value
* @param state Generally the "full entity state array", though could also be the natural id values array * @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. * @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} * 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. * @param source Enumeration representing how these values are coming into cache.
*/ */
void manageLocalNaturalIdCrossReference( void manageLocalNaturalIdCrossReference(
EntityPersister persister, EntityPersister persister,
Serializable id, Object id,
Object[] state, Object[] state,
Object[] previousState, Object[] previousState,
CachedNaturalIdValueSource source); CachedNaturalIdValueSource source);
/** /**
* Cleans up local cross-reference entries. * 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. * 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( void manageSharedNaturalIdCrossReference(
EntityPersister persister, EntityPersister persister,
Serializable id, Object id,
Object[] state, Object[] state,
Object[] previousState, Object[] previousState,
CachedNaturalIdValueSource source); CachedNaturalIdValueSource source);
/** /**
* Cleans up local cross-reference entries. * 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. * 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 * 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 * {@link PersistenceContext.NaturalIdHelper#INVALID_NATURAL_ID_REFERENCE} if the given natural ids are known to
* be invalid. * 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. * Find all the locally cached primary key cross-reference entries for the given persister.
* * @return
* @param persister The persister representing the entity type.
*
* @return The primary keys
*/ */
Collection<Serializable> getCachedPkResolutions(EntityPersister persister); Collection<?> getCachedPkResolutions(EntityPersister persister);
/** /**
* Part of the "load synchronization process". Responsible for maintaining cross-reference entries * 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 persister The persister representing the entity type.
* @param pk The primary key * @param pk The primary key
* @param entity The entity instance * @param entity The entity instance
* *
* @see #cleanupFromSynchronizations * @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 * 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 ); 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( public QueryParameters(
final Type[] positionalParameterTypes, final Type[] positionalParameterTypes,
final Object[] positionalParameterValues, final Object[] positionalParameterValues,

View File

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

View File

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

View File

@ -224,7 +224,7 @@ public interface SharedSessionContractImplementor
* *
* @return The entity key * @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. * Retrieves the interceptor currently in use by this event source.
@ -257,14 +257,14 @@ public interface SharedSessionContractImplementor
* <p/> * <p/>
* When <tt>eager</tt> is enabled, the object is eagerly fetched * 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; throws HibernateException;
/** /**
* Load an instance immediately. This method is only called when lazily initializing a proxy. * Load an instance immediately. This method is only called when lazily initializing a proxy.
* Do not return the 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 * Return the identifier of the persistent object, or null if
* not associated with the session * 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 * 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( persistenceContext.forEachCollectionEntry(
(coll, ce) -> { (coll, ce) -> {
if ( ce.isDorecreate() ) { if ( ce.isDorecreate() ) {
interceptor.onCollectionRecreate( coll, ce.getCurrentKey() ); interceptor.onCollectionRecreate( coll, (Serializable) ce.getCurrentKey() );
actionQueue.addAction( actionQueue.addAction(
new CollectionRecreateAction( new CollectionRecreateAction(
coll, coll,
@ -277,7 +277,7 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
); );
} }
if ( ce.isDoremove() ) { if ( ce.isDoremove() ) {
interceptor.onCollectionRemove( coll, ce.getLoadedKey() ); interceptor.onCollectionRemove( coll, (Serializable) ce.getLoadedKey() );
actionQueue.addAction( actionQueue.addAction(
new CollectionRemoveAction( new CollectionRemoveAction(
coll, coll,
@ -289,7 +289,7 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
); );
} }
if ( ce.isDoupdate() ) { if ( ce.isDoupdate() ) {
interceptor.onCollectionUpdate( coll, ce.getLoadedKey() ); interceptor.onCollectionUpdate( coll, (Serializable) ce.getLoadedKey() );
actionQueue.addAction( actionQueue.addAction(
new CollectionUpdateAction( new CollectionUpdateAction(
coll, coll,

View File

@ -43,7 +43,7 @@ public abstract class AbstractReassociateEventListener implements Serializable {
* *
* @return An EntityEntry representing the entity within this session. * @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() ) { if ( log.isTraceEnabled() ) {
log.tracev( log.tracev(

View File

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

View File

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

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.event.internal; package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.internal.Cascade; import org.hibernate.engine.internal.Cascade;
import org.hibernate.engine.internal.CascadePoint; import org.hibernate.engine.internal.CascadePoint;
@ -54,7 +52,7 @@ public class DefaultEvictEventListener implements EvictEventListener {
if ( object instanceof HibernateProxy ) { if ( object instanceof HibernateProxy ) {
final LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer(); final LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
final Serializable id = li.getIdentifier(); final Object id = li.getIdentifier();
if ( id == null ) { if ( id == null ) {
throw new IllegalArgumentException( "Could not determine identifier of proxy passed to evict()" ); 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 * 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 { 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 // 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 // and was saved outside the transaction forcing it to be delayed
return; return;
} }
if ( persister.canExtractIdOutOfEntity() ) { if ( persister.canExtractIdOutOfEntity() ) {
final Object oid = persister.getIdentifier( object, session );
Serializable oid = persister.getIdentifier( object, session );
if ( id == null ) { if ( id == null ) {
throw new AssertionFailure( "null id in " + persister.getEntityName() + " entry (don't flush the Session after an exception occurs)" ); 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() ) ) { if ( !persister.getIdentifierType().isEqual( id, oid, session.getFactory() ) ) {
throw new HibernateException( throw new HibernateException(
"identifier of an instance of " + persister.getEntityName() + " was altered from " "identifier of an instance of " + persister.getEntityName() + " was altered from "
@ -82,7 +83,6 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
); );
} }
} }
} }
private void checkNaturalId( private void checkNaturalId(
@ -370,7 +370,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
final boolean answerFromInterceptor = session.getInterceptor().onFlushDirty( final boolean answerFromInterceptor = session.getInterceptor().onFlushDirty(
entity, entity,
entry.getId(), (Serializable) entry.getId(),
values, values,
entry.getLoadedState(), entry.getLoadedState(),
persister.getPropertyNames(), persister.getPropertyNames(),
@ -511,12 +511,12 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
final SessionImplementor session = event.getSession(); final SessionImplementor session = event.getSession();
final EntityEntry entry = event.getEntityEntry(); final EntityEntry entry = event.getEntityEntry();
final EntityPersister persister = entry.getPersister(); final EntityPersister persister = entry.getPersister();
final Serializable id = entry.getId(); final Object id = entry.getId();
final Object[] loadedState = entry.getLoadedState(); final Object[] loadedState = entry.getLoadedState();
int[] dirtyProperties = session.getInterceptor().findDirty( int[] dirtyProperties = session.getInterceptor().findDirty(
entity, entity,
id, (Serializable) id,
values, values,
loadedState, loadedState,
persister.getPropertyNames(), persister.getPropertyNames(),
@ -606,7 +606,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
} }
else { else {
// dirty check against the database snapshot, if possible/necessary // 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 ) { if ( databaseSnapshot != null ) {
dirtyProperties = persister.findModified( databaseSnapshot, values, entity, session ); dirtyProperties = persister.findModified( databaseSnapshot, values, entity, session );
dirtyCheckPossible = true; dirtyCheckPossible = true;
@ -673,7 +673,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
@Override @Override
public Object getLoadedValue() { public Object getLoadedValue() {
if ( databaseSnapshot == null ) { if ( databaseSnapshot == null ) {
databaseSnapshot = getDatabaseSnapshot( event.getSession(), persister, event.getEntityEntry().getId() ); databaseSnapshot = getDatabaseSnapshot( persister, event.getEntityEntry().getId(), event.getSession() );
} }
return databaseSnapshot[index]; 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() ) { if ( dirtyProperties != null && dirtyProperties.length > 0 && LOG.isTraceEnabled() ) {
final String[] allPropertyNames = persister.getPropertyNames(); final String[] allPropertyNames = persister.getPropertyNames();
final String[] dirtyPropertyNames = new String[dirtyProperties.length]; 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(); final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
if ( persister.isSelectBeforeUpdateRequired() ) { if ( persister.isSelectBeforeUpdateRequired() ) {
Object[] snapshot = persistenceContext Object[] snapshot = persistenceContext.getDatabaseSnapshot( id, persister );
.getDatabaseSnapshot( id, persister );
if ( snapshot == null ) { if ( snapshot == null ) {
//do we even really need this? the update will fail anyway.... //do we even really need this? the update will fail anyway....
final StatisticsImplementor statistics = session.getFactory().getStatistics(); final StatisticsImplementor statistics = session.getFactory().getStatistics();
if ( statistics.isStatisticsEnabled() ) { if ( statistics.isStatisticsEnabled() ) {
statistics statistics.optimisticFailure( persister.getEntityName() );
.optimisticFailure( persister.getEntityName() );
} }
throw new StaleObjectStateException( persister.getEntityName(), id ); throw new StaleObjectStateException( persister.getEntityName(), id );
} }

View File

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

View File

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

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.event.internal; package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.TransientObjectException; import org.hibernate.TransientObjectException;
@ -68,7 +66,7 @@ public class DefaultLockEventListener extends AbstractLockUpgradeEventListener i
EntityEntry entry = persistenceContext.getEntry(entity); EntityEntry entry = persistenceContext.getEntry(entity);
if (entry==null) { if (entry==null) {
final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity ); 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 ) ) { if ( !ForeignKeys.isNotTransient( event.getEntityName(), entity, Boolean.FALSE, source ) ) {
throw new TransientObjectException( throw new TransientObjectException(
"cannot lock an unsaved transient instance: " + "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.PersistenceContext;
import org.hibernate.engine.spi.PersistentAttributeInterceptable; import org.hibernate.engine.spi.PersistentAttributeInterceptable;
import org.hibernate.engine.spi.PersistentAttributeInterceptor; import org.hibernate.engine.spi.PersistentAttributeInterceptor;
import org.hibernate.loader.spi.InternalFetchProfile;
import org.hibernate.engine.spi.SelfDirtinessTracker; import org.hibernate.engine.spi.SelfDirtinessTracker;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor; 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.event.spi.MergeEventListener;
import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.loader.spi.InternalFetchProfile;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer; import org.hibernate.proxy.LazyInitializer;
@ -148,7 +148,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
EntityEntry entry = persistenceContext.getEntry( entity ); EntityEntry entry = persistenceContext.getEntry( entity );
if ( entry == null ) { if ( entry == null ) {
EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity ); EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
Serializable id = persister.getIdentifier( entity, source ); Object id = persister.getIdentifier( entity, source );
if ( id != null ) { if ( id != null ) {
final EntityKey key = source.generateEntityKey( id, persister ); final EntityKey key = source.generateEntityKey( id, persister );
final Object managedEntity = persistenceContext.getEntity( key ); final Object managedEntity = persistenceContext.getEntity( key );
@ -218,7 +218,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
final String entityName = event.getEntityName(); final String entityName = event.getEntityName();
final EntityPersister persister = session.getEntityPersister( entityName, entity ); final EntityPersister persister = session.getEntityPersister( entityName, entity );
final Serializable id = persister.hasIdentifierProperty() final Object id = persister.hasIdentifierProperty()
? persister.getIdentifier( entity, session ) ? persister.getIdentifier( entity, session )
: null; : null;
@ -286,13 +286,13 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity ); final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
final String entityName = persister.getEntityName(); final String entityName = persister.getEntityName();
Serializable id = event.getRequestedId(); Object id = event.getRequestedId();
if ( id == null ) { if ( id == null ) {
id = persister.getIdentifier( entity, source ); id = persister.getIdentifier( entity, source );
} }
else { else {
// check that entity id = requestedId // 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() ) ) { if ( !persister.getIdentifierType().isEqual( id, entityId, source.getFactory() ) ) {
throw new HibernateException( "merge requested with id not matching id of passed entity" ); 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(); final PersistenceContext persistenceContext = source.getPersistenceContextInternal();
EntityEntry entry = persistenceContext.getEntry( entity ); EntityEntry entry = persistenceContext.getEntry( entity );
if ( entry == null ) { if ( entry == null ) {
Serializable id = persister.getIdentifier( entity, source ); Object id = persister.getIdentifier( entity, source );
if ( id != null ) { if ( id != null ) {
final EntityKey key = source.generateEntityKey( id, persister ); final EntityKey key = source.generateEntityKey( id, persister );
final Object managedEntity = persistenceContext.getEntity( key ); final Object managedEntity = persistenceContext.getEntity( key );

View File

@ -6,6 +6,8 @@
*/ */
package org.hibernate.event.internal; package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.action.internal.EntityIncrementVersionProcess; import org.hibernate.action.internal.EntityIncrementVersionProcess;
@ -69,7 +71,7 @@ public class DefaultPostLoadEventListener implements PostLoadEventListener, Call
if ( event.getPersister().implementsLifecycle() ) { if ( event.getPersister().implementsLifecycle() ) {
//log.debug( "calling onLoad()" ); //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; package org.hibernate.event.internal;
import java.io.Serializable;
import org.hibernate.event.spi.PreLoadEvent; import org.hibernate.event.spi.PreLoadEvent;
import org.hibernate.event.spi.PreLoadEventListener; import org.hibernate.event.spi.PreLoadEventListener;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
@ -19,16 +21,14 @@ import org.hibernate.persister.entity.EntityPersister;
public class DefaultPreLoadEventListener implements PreLoadEventListener { public class DefaultPreLoadEventListener implements PreLoadEventListener {
public void onPreLoad(PreLoadEvent event) { public void onPreLoad(PreLoadEvent event) {
EntityPersister persister = event.getPersister(); final EntityPersister persister = event.getPersister();
event.getSession() event.getSession().getInterceptor().onLoad(
.getInterceptor() event.getEntity(),
.onLoad( (Serializable) event.getId(),
event.getEntity(), event.getState(),
event.getId(), persister.getPropertyNames(),
event.getState(), persister.getPropertyTypes()
persister.getPropertyNames(), );
persister.getPropertyTypes()
);
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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