type ids as Object instead of Serializable

This commit is contained in:
Gavin King 2021-03-01 18:26:42 +01:00
parent abfa2de1d4
commit d4aa643630
44 changed files with 106 additions and 135 deletions

View File

@ -44,7 +44,7 @@ public interface Cache extends javax.persistence.Cache {
* @return True if the underlying cache contains corresponding data; false * @return True if the underlying cache contains corresponding data; false
* otherwise. * otherwise.
*/ */
boolean containsEntity(Class entityClass, Serializable identifier); boolean containsEntity(Class entityClass, Object identifier);
/** /**
* Determine whether the cache contains data for the given entity "instance". * Determine whether the cache contains data for the given entity "instance".
@ -57,7 +57,7 @@ public interface Cache extends javax.persistence.Cache {
* *
* @return True if the underlying cache contains corresponding data; false otherwise. * @return True if the underlying cache contains corresponding data; false otherwise.
*/ */
boolean containsEntity(String entityName, Serializable identifier); boolean containsEntity(String entityName, Object identifier);
/** /**
* Evicts the entity data for a particular entity "instance". * Evicts the entity data for a particular entity "instance".
@ -67,7 +67,7 @@ public interface Cache extends javax.persistence.Cache {
* *
* @since 5.3 * @since 5.3
*/ */
void evictEntityData(Class entityClass, Serializable identifier); void evictEntityData(Class entityClass, Object identifier);
/** /**
* Evicts the entity data for a particular entity "instance". * Evicts the entity data for a particular entity "instance".
@ -77,7 +77,7 @@ public interface Cache extends javax.persistence.Cache {
* *
* @since 5.3 * @since 5.3
*/ */
void evictEntityData(String entityName, Serializable identifier); void evictEntityData(String entityName, Object identifier);
/** /**
* Evicts all entity data from the given region (i.e. for all entities of * Evicts all entity data from the given region (i.e. for all entities of
@ -156,7 +156,7 @@ public interface Cache extends javax.persistence.Cache {
* @return True if the underlying cache contains corresponding data; false otherwise. * @return True if the underlying cache contains corresponding data; false otherwise.
*/ */
@SuppressWarnings( {"UnusedDeclaration"}) @SuppressWarnings( {"UnusedDeclaration"})
boolean containsCollection(String role, Serializable ownerIdentifier); boolean containsCollection(String role, Object ownerIdentifier);
/** /**
@ -167,7 +167,7 @@ public interface Cache extends javax.persistence.Cache {
* *
* @since 5.3 * @since 5.3
*/ */
void evictCollectionData(String role, Serializable ownerIdentifier); void evictCollectionData(String role, Object ownerIdentifier);
/** /**
* Evicts cached data for the given collection role * Evicts cached data for the given collection role
@ -271,7 +271,7 @@ public interface Cache extends javax.persistence.Cache {
* @deprecated Use {@link Cache#evictEntityData(Class, Serializable)} instead * @deprecated Use {@link Cache#evictEntityData(Class, Serializable)} instead
*/ */
@Deprecated @Deprecated
default void evictEntity(Class entityClass, Serializable identifier) { default void evictEntity(Class entityClass, Object identifier) {
evictEntityData( entityClass, identifier ); evictEntityData( entityClass, identifier );
} }
@ -284,7 +284,7 @@ public interface Cache extends javax.persistence.Cache {
* @deprecated Use {@link Cache#evictEntityData(String, Serializable)} instead * @deprecated Use {@link Cache#evictEntityData(String, Serializable)} instead
*/ */
@Deprecated @Deprecated
default void evictEntity(String entityName, Serializable identifier) { default void evictEntity(String entityName, Object identifier) {
evictEntityData( entityName, identifier ); evictEntityData( entityName, identifier );
} }

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate; package org.hibernate;
import java.io.Serializable;
import java.util.Optional; import java.util.Optional;
/** /**
@ -74,5 +73,5 @@ public interface SimpleNaturalIdLoadAccess<T> {
* *
* @return The persistent instance, if one, wrapped in Optional * @return The persistent instance, if one, wrapped in Optional
*/ */
Optional<T> loadOptional(Serializable naturalIdValue); Optional<T> loadOptional(Object naturalIdValue);
} }

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.cache.internal; package org.hibernate.cache.internal;
import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
@ -53,23 +52,23 @@ public class DisabledCaching implements CacheImplementor {
} }
@Override @Override
public boolean containsEntity(Class entityClass, Serializable identifier) { public boolean containsEntity(Class entityClass, Object identifier) {
return false; return false;
} }
@Override @Override
public boolean containsEntity(String entityName, Serializable identifier) { public boolean containsEntity(String entityName, Object identifier) {
return false; return false;
} }
@Override @Override
public void evictEntityData(Class entityClass, Serializable identifier) { public void evictEntityData(Class entityClass, Object identifier) {
// nothing to do // nothing to do
} }
@Override @Override
public void evictEntityData(String entityName, Serializable identifier) { public void evictEntityData(String entityName, Object identifier) {
// nothing to do // nothing to do
} }
@ -105,12 +104,12 @@ public class DisabledCaching implements CacheImplementor {
} }
@Override @Override
public boolean containsCollection(String role, Serializable ownerIdentifier) { public boolean containsCollection(String role, Object ownerIdentifier) {
return false; return false;
} }
@Override @Override
public void evictCollectionData(String role, Serializable ownerIdentifier) { public void evictCollectionData(String role, Object ownerIdentifier) {
// nothing to do // nothing to do
} }

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.cache.internal; package org.hibernate.cache.internal;
import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
@ -220,12 +219,12 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
// Entity data // Entity data
@Override @Override
public boolean containsEntity(Class entityClass, Serializable identifier) { public boolean containsEntity(Class entityClass, Object identifier) {
return containsEntity( entityClass.getName(), identifier ); return containsEntity( entityClass.getName(), identifier );
} }
@Override @Override
public boolean containsEntity(String entityName, Serializable identifier) { public boolean containsEntity(String entityName, Object identifier) {
final EntityPersister entityDescriptor = sessionFactory.getMetamodel().entityPersister( entityName ); final EntityPersister entityDescriptor = sessionFactory.getMetamodel().entityPersister( entityName );
final EntityDataAccess cacheAccess = entityDescriptor.getCacheAccessStrategy(); final EntityDataAccess cacheAccess = entityDescriptor.getCacheAccessStrategy();
if ( cacheAccess == null ) { if ( cacheAccess == null ) {
@ -237,12 +236,12 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
} }
@Override @Override
public void evictEntityData(Class entityClass, Serializable identifier) { public void evictEntityData(Class entityClass, Object identifier) {
evictEntityData( entityClass.getName(), identifier ); evictEntityData( entityClass.getName(), identifier );
} }
@Override @Override
public void evictEntityData(String entityName, Serializable identifier) { public void evictEntityData(String entityName, Object identifier) {
final EntityPersister entityDescriptor = sessionFactory.getMetamodel().entityPersister( entityName ); final EntityPersister entityDescriptor = sessionFactory.getMetamodel().entityPersister( entityName );
final EntityDataAccess cacheAccess = entityDescriptor.getCacheAccessStrategy(); final EntityDataAccess cacheAccess = entityDescriptor.getCacheAccessStrategy();
if ( cacheAccess == null ) { if ( cacheAccess == null ) {
@ -344,7 +343,7 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
// Collection data // Collection data
@Override @Override
public boolean containsCollection(String role, Serializable ownerIdentifier) { public boolean containsCollection(String role, Object ownerIdentifier) {
final CollectionPersister collectionDescriptor = sessionFactory.getMetamodel() final CollectionPersister collectionDescriptor = sessionFactory.getMetamodel()
.collectionPersister( role ); .collectionPersister( role );
@ -358,7 +357,7 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
} }
@Override @Override
public void evictCollectionData(String role, Serializable ownerIdentifier) { public void evictCollectionData(String role, Object ownerIdentifier) {
final CollectionPersister collectionDescriptor = sessionFactory.getMetamodel() final CollectionPersister collectionDescriptor = sessionFactory.getMetamodel()
.collectionPersister( role ); .collectionPersister( role );
@ -569,13 +568,13 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
@Override @Override
public boolean contains(Class cls, Object primaryKey) { public boolean contains(Class cls, Object primaryKey) {
// JPA // JPA
return containsEntity( cls, (Serializable) primaryKey ); return containsEntity( cls, primaryKey );
} }
@Override @Override
public void evict(Class cls, Object primaryKey) { public void evict(Class cls, Object primaryKey) {
// JPA call // JPA call
evictEntityData( cls, (Serializable) primaryKey ); evictEntityData( cls, primaryKey );
} }
@Override @Override

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.dialect.identity; package org.hibernate.dialect.identity;
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 GetGeneratedKeysDelegate
} }
@Override @Override
public Serializable executeAndExtract(PreparedStatement insert, SharedSessionContractImplementor session) public Object executeAndExtract(PreparedStatement insert, SharedSessionContractImplementor session)
throws SQLException { throws SQLException {
session.getJdbcCoordinator().getResultSetReturn().executeUpdate( insert ); session.getJdbcCoordinator().getResultSetReturn().executeUpdate( insert );
ResultSet rs = null; ResultSet rs = null;

View File

@ -112,7 +112,7 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
protected AbstractEntityEntry( protected AbstractEntityEntry(
final SessionFactoryImplementor factory, final SessionFactoryImplementor factory,
final String entityName, final String entityName,
final Serializable id, final Object id,
final Status status, final Status status,
final Status previousStatus, final Status previousStatus,
final Object[] loadedState, final Object[] loadedState,

View File

@ -62,7 +62,7 @@ public class BatchFetchQueueHelper {
if ( LOG.isDebugEnabled() ) { if ( LOG.isDebugEnabled() ) {
LOG.debug( "Entities of type [" + persister.getEntityName() + "] not found; IDs: " + idSet ); LOG.debug( "Entities of type [" + persister.getEntityName() + "] not found; IDs: " + idSet );
} }
for ( Serializable id : idSet ) { for ( Object id : idSet ) {
removeBatchLoadableEntityKey( id, persister, session ); removeBatchLoadableEntityKey( id, persister, session );
} }
} }

View File

@ -8,7 +8,6 @@ package org.hibernate.engine.internal;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.Serializable;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.LockMode; import org.hibernate.LockMode;
@ -65,7 +64,7 @@ public final class ImmutableEntityEntry extends AbstractEntityEntry {
private ImmutableEntityEntry( private ImmutableEntityEntry(
final SessionFactoryImplementor factory, final SessionFactoryImplementor factory,
final String entityName, final String entityName,
final Serializable id, final Object id,
final Status status, final Status status,
final Status previousStatus, final Status previousStatus,
final Object[] loadedState, final Object[] loadedState,
@ -115,7 +114,7 @@ public final class ImmutableEntityEntry extends AbstractEntityEntry {
return new ImmutableEntityEntry( return new ImmutableEntityEntry(
persistenceContext.getSession().getFactory(), persistenceContext.getSession().getFactory(),
(String) ois.readObject(), (String) ois.readObject(),
(Serializable) ois.readObject(), ois.readObject(),
Status.valueOf( (String) ois.readObject() ), Status.valueOf( (String) ois.readObject() ),
( previousStatusString = (String) ois.readObject() ).length() == 0 ( previousStatusString = (String) ois.readObject() ).length() == 0
? null ? null

View File

@ -8,7 +8,6 @@ package org.hibernate.engine.internal;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.Serializable;
import org.hibernate.EntityMode; import org.hibernate.EntityMode;
import org.hibernate.LockMode; import org.hibernate.LockMode;
@ -36,7 +35,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,
@ -73,7 +72,7 @@ public final class MutableEntityEntry extends AbstractEntityEntry {
private MutableEntityEntry( private MutableEntityEntry(
final SessionFactoryImplementor factory, final SessionFactoryImplementor factory,
final String entityName, final String entityName,
final Serializable id, final Object id,
final Status status, final Status status,
final Status previousStatus, final Status previousStatus,
final Object[] loadedState, final Object[] loadedState,
@ -108,7 +107,7 @@ public final class MutableEntityEntry extends AbstractEntityEntry {
return new MutableEntityEntry( return new MutableEntityEntry(
persistenceContext.getSession().getFactory(), persistenceContext.getSession().getFactory(),
(String) ois.readObject(), (String) ois.readObject(),
(Serializable) ois.readObject(), ois.readObject(),
Status.valueOf( (String) ois.readObject() ), Status.valueOf( (String) ois.readObject() ),
( previousStatusString = (String) ois.readObject() ).length() == 0 ( previousStatusString = (String) ois.readObject() ).length() == 0
? null ? null

View File

@ -65,11 +65,11 @@ public class UnsavedValueFactory {
if ( unsavedValue == null ) { if ( unsavedValue == null ) {
if ( identifierGetter != null && constructor != null ) { if ( identifierGetter != null && constructor != null ) {
// use the id value of a newly instantiated instance as the unsaved-value // use the id value of a newly instantiated instance as the unsaved-value
final Serializable defaultValue = (Serializable) identifierGetter.get( instantiate( constructor ) ); final Object defaultValue = identifierGetter.get( instantiate( constructor ) );
return new IdentifierValue( defaultValue ); return new IdentifierValue( defaultValue );
} }
else if ( identifierGetter != null && (identifierType instanceof PrimitiveType) ) { else if ( identifierGetter != null && (identifierType instanceof PrimitiveType) ) {
final Serializable defaultValue = ( (PrimitiveType) identifierType ).getDefaultValue(); final Object defaultValue = ( (PrimitiveType) identifierType ).getDefaultValue();
return new IdentifierValue( defaultValue ); return new IdentifierValue( defaultValue );
} }
else { else {
@ -90,7 +90,7 @@ public class UnsavedValueFactory {
} }
else { else {
try { try {
return new IdentifierValue( (Serializable) ( (IdentifierType) identifierType ).stringToObject( unsavedValue ) ); return new IdentifierValue( ( (IdentifierType) identifierType ).stringToObject( unsavedValue ) );
} }
catch ( ClassCastException cce ) { catch ( ClassCastException cce ) {
throw new MappingException( "Bad identifier type: " + identifierType.getName() ); throw new MappingException( "Bad identifier type: " + identifierType.getName() );

View File

@ -133,7 +133,7 @@ public final class CollectionEntry implements Serializable {
private CollectionEntry( private CollectionEntry(
String role, String role,
Serializable snapshot, Serializable snapshot,
Serializable loadedKey, Object loadedKey,
SessionFactoryImplementor factory) { SessionFactoryImplementor factory) {
this.role = role; this.role = role;
this.snapshot = snapshot; this.snapshot = snapshot;
@ -430,8 +430,8 @@ public final class CollectionEntry implements Serializable {
return new CollectionEntry( return new CollectionEntry(
(String) ois.readObject(), (String) ois.readObject(),
(Serializable) ois.readObject(), (Serializable) ois.readObject(),
(Serializable) ois.readObject(), ois.readObject(),
(session == null ? null : session.getFactory()) session == null ? null : session.getFactory()
); );
} }
} }

View File

@ -70,8 +70,8 @@ public final class EntityKey implements Serializable {
return identifier; return identifier;
} }
public Serializable getIdentifier() { public Object getIdentifier() {
return (Serializable) identifier; return identifier;
} }
public String getEntityName() { public String getEntityName() {
@ -147,7 +147,7 @@ public final class EntityKey implements Serializable {
* @throws ClassNotFoundException Thrown by Java I/O * @throws ClassNotFoundException Thrown by Java I/O
*/ */
public static EntityKey deserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory) throws IOException, ClassNotFoundException { public static EntityKey deserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory) throws IOException, ClassNotFoundException {
final Serializable id = (Serializable) ois.readObject(); final Object id = ois.readObject();
final String entityName = (String) ois.readObject(); final String entityName = (String) ois.readObject();
final EntityPersister entityPersister = sessionFactory.getEntityPersister( entityName ); final EntityPersister entityPersister = sessionFactory.getEntityPersister( entityName );
return new EntityKey(id, entityPersister); return new EntityKey(id, entityPersister);

View File

@ -23,7 +23,7 @@ import org.jboss.logging.Logger;
public class IdentifierValue implements UnsavedValueStrategy { public class IdentifierValue implements UnsavedValueStrategy {
private static final Logger LOG = CoreLogging.logger( IdentifierValue.class ); private static final Logger LOG = CoreLogging.logger( IdentifierValue.class );
private final Serializable value; private final Object value;
/** /**
* Always assume the transient instance is newly instantiated * Always assume the transient instance is newly instantiated
@ -36,8 +36,8 @@ public class IdentifierValue implements UnsavedValueStrategy {
} }
@Override @Override
public Serializable getDefaultValue(Object currentValue) { public Object getDefaultValue(Object currentValue) {
return (Serializable) currentValue; return currentValue;
} }
@Override @Override
@ -57,8 +57,8 @@ public class IdentifierValue implements UnsavedValueStrategy {
} }
@Override @Override
public Serializable getDefaultValue(Object currentValue) { public Object getDefaultValue(Object currentValue) {
return (Serializable) currentValue; return currentValue;
} }
@Override @Override
@ -118,7 +118,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
* Assume the transient instance is newly instantiated if * Assume the transient instance is newly instantiated if
* its identifier is null or equal to <tt>value</tt> * its identifier is null or equal to <tt>value</tt>
*/ */
public IdentifierValue(Serializable value) { public IdentifierValue(Object value) {
this.value = value; this.value = value;
} }
@ -132,7 +132,7 @@ public class IdentifierValue implements UnsavedValueStrategy {
} }
@Override @Override
public Serializable getDefaultValue(Object currentValue) { public Object getDefaultValue(Object currentValue) {
return value; return value;
} }

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.NonUniqueObjectException; import org.hibernate.NonUniqueObjectException;
@ -166,7 +164,7 @@ public class DefaultLoadEventListener implements LoadEventListener {
final EntityKey parentEntityKey = session.generateEntityKey( event.getEntityId(), parentPersister ); final EntityKey parentEntityKey = session.generateEntityKey( event.getEntityId(), parentPersister );
final Object parent = doLoad( event, parentPersister, parentEntityKey, options ); final Object parent = doLoad( event, parentPersister, parentEntityKey, options );
final Serializable dependent = (Serializable) dependentPersister.instantiate( parent, session ); final Object dependent = dependentPersister.instantiate( parent, session );
dependentPersister.setPropertyValues( dependent, new Object[] {parent} ); dependentPersister.setPropertyValues( dependent, new Object[] {parent} );
final EntityKey dependentEntityKey = session.generateEntityKey( dependent, dependentPersister ); final EntityKey dependentEntityKey = session.generateEntityKey( dependent, dependentPersister );
event.setEntityId( dependent ); event.setEntityId( dependent );

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.event.internal; package org.hibernate.event.internal;
import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
@ -262,7 +261,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
private void saveTransientEntity( private void saveTransientEntity(
Object entity, Object entity,
String entityName, String entityName,
Serializable requestedId, Object requestedId,
EventSource source, EventSource source,
Map copyCache) { Map copyCache) {
//this bit is only *really* absolutely necessary for handling //this bit is only *really* absolutely necessary for handling
@ -299,7 +298,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
} }
// we must clone embedded composite identifiers or we will get back the same instance that we pass in // we must clone embedded composite identifiers or we will get back the same instance that we pass in
final Serializable clonedIdentifier = (Serializable) persister.getIdentifierType().deepCopy( id, source.getFactory() ); final Object clonedIdentifier = persister.getIdentifierType().deepCopy( id, source.getFactory() );
// apply the special MERGE fetch profile and perform the resolution (Session#get) // apply the special MERGE fetch profile and perform the resolution (Session#get)
final Object result = source.getLoadQueryInfluencers().fromInternalFetchProfile( final Object result = source.getLoadQueryInfluencers().fromInternalFetchProfile(

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.event.spi; package org.hibernate.event.spi;
import java.io.Serializable;
/** /**
* An event class for merge() and saveOrUpdateCopy() * An event class for merge() and saveOrUpdateCopy()
* *
@ -16,7 +14,7 @@ import java.io.Serializable;
public class MergeEvent extends AbstractEvent { public class MergeEvent extends AbstractEvent {
private Object original; private Object original;
private Serializable requestedId; private Object requestedId;
private String entityName; private String entityName;
private Object entity; private Object entity;
private Object result; private Object result;
@ -26,7 +24,7 @@ public class MergeEvent extends AbstractEvent {
this.entityName = entityName; this.entityName = entityName;
} }
public MergeEvent(String entityName, Object original, Serializable id, EventSource source) { public MergeEvent(String entityName, Object original, Object id, EventSource source) {
this(entityName, original, source); this(entityName, original, source);
this.requestedId = id; this.requestedId = id;
if ( requestedId == null ) { if ( requestedId == null ) {
@ -54,11 +52,11 @@ public class MergeEvent extends AbstractEvent {
this.original = object; this.original = object;
} }
public Serializable getRequestedId() { public Object getRequestedId() {
return requestedId; return requestedId;
} }
public void setRequestedId(Serializable requestedId) { public void setRequestedId(Object requestedId) {
this.requestedId = requestedId; this.requestedId = requestedId;
} }

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.event.spi; package org.hibernate.event.spi;
import java.io.Serializable;
import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.EntityEntry;
/** /**
@ -29,7 +27,7 @@ public class SaveOrUpdateEvent extends AbstractEvent {
this.entityName = entityName; this.entityName = entityName;
} }
public SaveOrUpdateEvent(String entityName, Object original, Serializable id, EventSource source) { public SaveOrUpdateEvent(String entityName, Object original, Object id, EventSource source) {
this(entityName, original, source); this(entityName, original, source);
this.requestedId = id; this.requestedId = id;
if ( requestedId == null ) { if ( requestedId == null ) {

View File

@ -69,12 +69,12 @@ public final class IdentifierGeneratorHelper {
* @throws SQLException Can be thrown while accessing the result set * @throws SQLException Can be thrown while accessing the result set
* @throws HibernateException Indicates a problem reading back a generated identity value. * @throws HibernateException Indicates a problem reading back a generated identity value.
*/ */
public static Serializable getGeneratedIdentity(ResultSet rs, String identifier, Type type, Dialect dialect) public static Object getGeneratedIdentity(ResultSet rs, String identifier, Type type, Dialect dialect)
throws SQLException, HibernateException { throws SQLException, HibernateException {
if ( !rs.next() ) { if ( !rs.next() ) {
throw new HibernateException( "The database returned no natively generated identity value" ); throw new HibernateException( "The database returned no natively generated identity value" );
} }
final Serializable id = get( rs, identifier, type, dialect ); final Object id = get( rs, identifier, type, dialect );
LOG.debugf( "Natively generated identity: %s", id ); LOG.debugf( "Natively generated identity: %s", id );
return id; return id;
} }
@ -93,7 +93,7 @@ public final class IdentifierGeneratorHelper {
* @throws SQLException Indicates problems access the result set * @throws SQLException Indicates problems access the result set
* @throws IdentifierGenerationException Indicates an unknown type. * @throws IdentifierGenerationException Indicates an unknown type.
*/ */
public static Serializable get(ResultSet rs, String identifier, Type type, Dialect dialect) public static Object get(ResultSet rs, String identifier, Type type, Dialect dialect)
throws SQLException, IdentifierGenerationException { throws SQLException, IdentifierGenerationException {
if ( ResultSetIdentifierConsumer.class.isInstance( type ) ) { if ( ResultSetIdentifierConsumer.class.isInstance( type ) ) {
return ( (ResultSetIdentifierConsumer) type ).consumeIdentifier( rs ); return ( (ResultSetIdentifierConsumer) type ).consumeIdentifier( rs );
@ -153,7 +153,7 @@ public final class IdentifierGeneratorHelper {
} }
} }
private static Serializable extractIdentifier(ResultSet rs, String identifier, Type type, Class clazz) private static Object extractIdentifier(ResultSet rs, String identifier, Type type, Class clazz)
throws SQLException { throws SQLException {
if ( clazz == Long.class ) { if ( clazz == Long.class ) {
return rs.getLong( identifier ); return rs.getLong( identifier );

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.id; package org.hibernate.id;
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;
@ -82,7 +81,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator {
} }
@Override @Override
public Serializable executeAndExtract(PreparedStatement insert, SharedSessionContractImplementor session) public Object executeAndExtract(PreparedStatement insert, SharedSessionContractImplementor session)
throws SQLException { throws SQLException {
ResultSet rs = session.getJdbcCoordinator().getResultSetReturn().execute( insert ); ResultSet rs = session.getJdbcCoordinator().getResultSetReturn().execute( insert );
try { try {
@ -98,7 +97,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator {
} }
} }
public Serializable determineGeneratedIdentifier(SharedSessionContractImplementor session, Object entity) { public Object determineGeneratedIdentifier(SharedSessionContractImplementor session, Object entity) {
throw new AssertionFailure( "insert statement returns generated value" ); throw new AssertionFailure( "insert statement returns generated value" );
} }
} }
@ -132,7 +131,7 @@ public class IdentityGenerator extends AbstractPostInsertGenerator {
} }
@Override @Override
protected Serializable getResult( protected Object getResult(
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
ResultSet rs, ResultSet rs,
Object object) throws SQLException { Object object) throws SQLException {

View File

@ -5,7 +5,7 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/ */
package org.hibernate.id; package org.hibernate.id;
import java.io.Serializable;
import java.sql.ResultSet; import java.sql.ResultSet;
/** /**
@ -25,5 +25,5 @@ public interface ResultSetIdentifierConsumer {
* the identifier value. * the identifier value.
* @return The identifier value. * @return The identifier value.
*/ */
public Serializable consumeIdentifier(ResultSet resultSet); public Object consumeIdentifier(ResultSet resultSet);
} }

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.id; package org.hibernate.id;
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;
@ -121,7 +120,7 @@ public class SelectGenerator extends AbstractPostInsertGenerator implements Conf
uniqueKeyType.nullSafeSet( ps, uniqueKeyValue, 1, session ); uniqueKeyType.nullSafeSet( ps, uniqueKeyValue, 1, session );
} }
protected Serializable getResult( protected Object getResult(
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
ResultSet rs, ResultSet rs,
Object entity) throws SQLException { Object entity) throws SQLException {
@ -131,7 +130,7 @@ public class SelectGenerator extends AbstractPostInsertGenerator implements Conf
uniqueKeyPropertyName uniqueKeyPropertyName
); );
} }
return (Serializable) idType.nullSafeGet( return idType.nullSafeGet(
rs, rs,
persister.getRootTableKeyColumnNames(), persister.getRootTableKeyColumnNames(),
session, session,

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.id; package org.hibernate.id;
import java.io.Serializable;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
@ -90,7 +89,7 @@ public class SequenceIdentityGenerator
} }
@Override @Override
protected Serializable executeAndExtract(PreparedStatement insert, SharedSessionContractImplementor session) protected Object executeAndExtract(PreparedStatement insert, SharedSessionContractImplementor session)
throws SQLException { throws SQLException {
session.getJdbcCoordinator().getResultSetReturn().executeUpdate( insert ); session.getJdbcCoordinator().getResultSetReturn().executeUpdate( insert );
return IdentifierGeneratorHelper.getGeneratedIdentity( return IdentifierGeneratorHelper.getGeneratedIdentity(

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.id.insert; package org.hibernate.id.insert;
import java.io.Serializable;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
@ -31,7 +30,7 @@ public abstract class AbstractReturningDelegate implements InsertGeneratedIdenti
} }
@Override @Override
public final Serializable performInsert( public final Object performInsert(
String insertSQL, String insertSQL,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Binder binder) { Binder binder) {
@ -61,7 +60,7 @@ public abstract class AbstractReturningDelegate implements InsertGeneratedIdenti
protected abstract PreparedStatement prepare(String insertSQL, SharedSessionContractImplementor session) throws SQLException; protected abstract PreparedStatement prepare(String insertSQL, SharedSessionContractImplementor session) throws SQLException;
protected abstract Serializable executeAndExtract(PreparedStatement insert, SharedSessionContractImplementor session) protected abstract Object executeAndExtract(PreparedStatement insert, SharedSessionContractImplementor session)
throws SQLException; throws SQLException;
protected void releaseStatement(PreparedStatement insert, SharedSessionContractImplementor session) { protected void releaseStatement(PreparedStatement insert, SharedSessionContractImplementor session) {

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.id.insert; package org.hibernate.id.insert;
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;
@ -30,7 +29,7 @@ public abstract class AbstractSelectingDelegate implements InsertGeneratedIdenti
} }
@Override @Override
public final Serializable performInsert( public final Object performInsert(
String insertSQL, String insertSQL,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Binder binder) { Binder binder) {
@ -123,7 +122,7 @@ public abstract class AbstractSelectingDelegate implements InsertGeneratedIdenti
* *
* @throws SQLException * @throws SQLException
*/ */
protected abstract Serializable getResult( protected abstract Object getResult(
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
ResultSet rs, ResultSet rs,
Object entity) throws SQLException; Object entity) throws SQLException;

View File

@ -6,8 +6,6 @@
*/ */
package org.hibernate.id.insert; package org.hibernate.id.insert;
import java.io.Serializable;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
/** /**
@ -40,6 +38,6 @@ public interface InsertGeneratedIdentifierDelegate {
* *
* @return The generated identifier value. * @return The generated identifier value.
*/ */
Serializable performInsert(String insertSQL, SharedSessionContractImplementor session, Binder binder); Object performInsert(String insertSQL, SharedSessionContractImplementor session, Binder binder);
} }

View File

@ -538,7 +538,7 @@ public class SessionImpl
// logically, is PersistentContext the "thing" to which an interceptor gets attached? // logically, is PersistentContext the "thing" to which an interceptor gets attached?
final Object result = persistenceContext.getEntity( key ); final Object result = persistenceContext.getEntity( key );
if ( result == null ) { if ( result == null ) {
final Object newObject = getInterceptor().getEntity( key.getEntityName(), key.getIdentifier() ); final Object newObject = getInterceptor().getEntity( key.getEntityName(), (Serializable) key.getIdentifier() );
if ( newObject != null ) { if ( newObject != null ) {
lock( newObject, LockMode.NONE ); lock( newObject, LockMode.NONE );
} }

View File

@ -475,7 +475,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
return result; return result;
} }
final Object newObject = getInterceptor().getEntity( key.getEntityName(), key.getIdentifier() ); final Object newObject = getInterceptor().getEntity( key.getEntityName(), (Serializable) key.getIdentifier() );
if ( newObject != null ) { if ( newObject != null ) {
persistenceContext.addEntity( key, newObject ); persistenceContext.addEntity( key, newObject );
return newObject; return newObject;

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.loader.access; package org.hibernate.loader.access;
import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -115,7 +114,7 @@ public class SimpleNaturalIdLoadAccessImpl<T>
} }
@Override @Override
public Optional<T> loadOptional(Serializable naturalIdValue) { public Optional<T> loadOptional(Object naturalIdValue) {
return Optional.ofNullable( load( naturalIdValue ) ); return Optional.ofNullable( load( naturalIdValue ) );
} }
} }

View File

@ -9,7 +9,6 @@ package org.hibernate.metamodel.model.domain;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;

View File

@ -1899,7 +1899,7 @@ public abstract class AbstractCollectionPersister
* @deprecated Use {@link #doProcessQueuedOps(PersistentCollection, Object, SharedSessionContractImplementor)} * @deprecated Use {@link #doProcessQueuedOps(PersistentCollection, Object, SharedSessionContractImplementor)}
*/ */
@Deprecated @Deprecated
protected void doProcessQueuedOps(PersistentCollection collection, Serializable key, protected void doProcessQueuedOps(PersistentCollection collection, Object key,
int nextIndex, SharedSessionContractImplementor session) int nextIndex, SharedSessionContractImplementor session)
throws HibernateException { throws HibernateException {
doProcessQueuedOps( collection, key, session ); doProcessQueuedOps( collection, key, session );

View File

@ -3173,7 +3173,7 @@ public abstract class AbstractEntityPersister
} }
public int dehydrate( public int dehydrate(
Serializable id, Object id,
Object[] fields, Object[] fields,
boolean[] includeProperty, boolean[] includeProperty,
boolean[][] includeColumns, boolean[][] includeColumns,
@ -3267,7 +3267,7 @@ public abstract class AbstractEntityPersister
*/ */
public Object[] hydrate( public Object[] hydrate(
final ResultSet rs, final ResultSet rs,
final Serializable id, final Object id,
final Object object, final Object object,
final Loadable rootLoadable, final Loadable rootLoadable,
final String[][] suffixedPropertyColumns, final String[][] suffixedPropertyColumns,
@ -3386,7 +3386,7 @@ public abstract class AbstractEntityPersister
* This form is used for PostInsertIdentifierGenerator-style ids (IDENTITY, * This form is used for PostInsertIdentifierGenerator-style ids (IDENTITY,
* select, etc). * select, etc).
*/ */
public Serializable insert( public Object insert(
final Object[] fields, final Object[] fields,
final boolean[] notNull, final boolean[] notNull,
String sql, String sql,
@ -3999,13 +3999,13 @@ public abstract class AbstractEntityPersister
} }
} }
public Serializable insert(Object[] fields, Object object, SharedSessionContractImplementor session) public Object insert(Object[] fields, Object object, SharedSessionContractImplementor session)
throws HibernateException { throws HibernateException {
// apply any pre-insert in-memory value generation // apply any pre-insert in-memory value generation
preInsertInMemoryValueGeneration( fields, object, session ); preInsertInMemoryValueGeneration( fields, object, session );
final int span = getTableSpan(); final int span = getTableSpan();
final Serializable id; final Object id;
if ( entityMetamodel.isDynamicInsert() ) { if ( entityMetamodel.isDynamicInsert() ) {
// For the case of dynamic-insert="true", we need to generate the INSERT SQL // For the case of dynamic-insert="true", we need to generate the INSERT SQL
boolean[] notNull = getPropertiesToInsert( fields ); boolean[] notNull = getPropertiesToInsert( fields );
@ -4631,7 +4631,7 @@ public abstract class AbstractEntityPersister
final EnhancementAsProxyLazinessInterceptor proxyInterceptor = (EnhancementAsProxyLazinessInterceptor) currentInterceptor; final EnhancementAsProxyLazinessInterceptor proxyInterceptor = (EnhancementAsProxyLazinessInterceptor) currentInterceptor;
final EntityKey entityKey = proxyInterceptor.getEntityKey(); final EntityKey entityKey = proxyInterceptor.getEntityKey();
final Serializable identifier = entityKey.getIdentifier(); final Object identifier = entityKey.getIdentifier();
LoadEvent loadEvent = new LoadEvent( identifier, entity, (EventSource)session, false ); LoadEvent loadEvent = new LoadEvent( identifier, entity, (EventSource)session, false );

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.persister.entity; package org.hibernate.persister.entity;
import java.io.Serializable;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -85,7 +84,7 @@ public interface Loadable extends EntityPersister {
*/ */
Object[] hydrate( Object[] hydrate(
ResultSet rs, ResultSet rs,
Serializable id, Object id,
Object object, Object object,
Loadable rootLoadable, Loadable rootLoadable,
String[][] suffixedPropertyColumns, String[][] suffixedPropertyColumns,

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.sql.results.graph.collection; package org.hibernate.sql.results.graph.collection;
import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -33,7 +32,7 @@ public interface LoadingCollectionEntry {
/** /**
* The collection key. * The collection key.
*/ */
Serializable getKey(); Object getKey();
/** /**
* The collection instance being loaded * The collection instance being loaded

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.sql.results.graph.entity; package org.hibernate.sql.results.graph.entity;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.List; import java.util.List;
@ -603,7 +602,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
// return; // return;
// } // }
final Serializable entityIdentifier = entityKey.getIdentifier(); final Object entityIdentifier = entityKey.getIdentifier();
if ( EntityLoadingLogger.TRACE_ENABLED ) { if ( EntityLoadingLogger.TRACE_ENABLED ) {
EntityLoadingLogger.LOGGER.tracef( EntityLoadingLogger.LOGGER.tracef(

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.sql.results.internal; package org.hibernate.sql.results.internal;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -57,9 +56,9 @@ public class LoadingCollectionEntryImpl implements LoadingCollectionEntry {
return initializer; return initializer;
} }
@Override public Serializable getKey() { @Override public Object getKey() {
// todo (6.0) : change from Serializable to Object // todo (6.0) : change from Serializable to Object
return (Serializable) key; return key;
} }
@Override public PersistentCollection getCollectionInstance() { @Override public PersistentCollection getCollectionInstance() {

View File

@ -41,7 +41,6 @@ import org.hibernate.proxy.ProxyFactory;
import org.hibernate.tuple.IdentifierProperty; import org.hibernate.tuple.IdentifierProperty;
import org.hibernate.tuple.Instantiator; import org.hibernate.tuple.Instantiator;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
import org.hibernate.type.BasicType;
import org.hibernate.type.ComponentType; import org.hibernate.type.ComponentType;
import org.hibernate.type.CompositeType; import org.hibernate.type.CompositeType;
import org.hibernate.type.EntityType; import org.hibernate.type.EntityType;
@ -522,10 +521,10 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
} }
else { else {
//reset the id //reset the id
Serializable result = identifierProperty Object result = identifierProperty
.getUnsavedValue() .getUnsavedValue()
.getDefaultValue( currentId ); .getDefaultValue( currentId );
setIdentifier( entity, result, session ); setIdentifier( entity, (Serializable) result, session );
//reset the version //reset the version
VersionProperty versionProperty = entityMetamodel.getVersionProperty(); VersionProperty versionProperty = entityMetamodel.getVersionProperty();
if ( entityMetamodel.isVersioned() ) { if ( entityMetamodel.isVersioned() ) {

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.tuple.entity; package org.hibernate.tuple.entity;
import java.io.Serializable;
import java.util.Set; import java.util.Set;
import org.hibernate.LockMode; import org.hibernate.LockMode;
@ -139,7 +138,7 @@ public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhanc
@Override @Override
public PersistentAttributeInterceptable createEnhancedProxy(EntityKey entityKey, boolean addEmptyEntry, SharedSessionContractImplementor session) { public PersistentAttributeInterceptable createEnhancedProxy(EntityKey entityKey, boolean addEmptyEntry, SharedSessionContractImplementor session) {
final EntityPersister persister = entityKey.getPersister(); final EntityPersister persister = entityKey.getPersister();
final Serializable identifier = entityKey.getIdentifier(); final Object identifier = entityKey.getIdentifier();
final PersistenceContext persistenceContext = session.getPersistenceContext(); final PersistenceContext persistenceContext = session.getPersistenceContext();
// first, instantiate the entity instance to use as the proxy // first, instantiate the entity instance to use as the proxy

View File

@ -249,7 +249,7 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
public Object hydrate(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) public Object hydrate(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
throws HibernateException, SQLException { throws HibernateException, SQLException {
final String entityName = (String) discriminatorType.nullSafeGet( rs, names[0], session, owner ); final String entityName = (String) discriminatorType.nullSafeGet( rs, names[0], session, owner );
final Serializable id = (Serializable) identifierType.nullSafeGet( rs, names[1], session, owner ); final Object id = identifierType.nullSafeGet( rs, names[1], session, owner );
return new ObjectTypeCacheEntry( entityName, id ); return new ObjectTypeCacheEntry( entityName, id );
} }

View File

@ -292,7 +292,7 @@ public abstract class CollectionType extends AbstractType implements Association
return null; return null;
} }
else { else {
final Serializable key = (Serializable) getPersister(session) final Object key = getPersister(session)
.getKeyType() .getKeyType()
.assemble( cached, session, owner); .assemble( cached, session, owner);
return resolveKey( key, session, owner, null ); return resolveKey( key, session, owner, null );

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.type; package org.hibernate.type;
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;
@ -427,7 +426,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
public Object resolve(Object value, SharedSessionContractImplementor session, Object owner, Boolean overridingEager) throws HibernateException { public Object resolve(Object value, SharedSessionContractImplementor session, Object owner, Boolean overridingEager) throws HibernateException {
if ( value != null && !isNull( owner, session ) ) { if ( value != null && !isNull( owner, session ) ) {
if ( isReferenceToPrimaryKey() ) { if ( isReferenceToPrimaryKey() ) {
return resolveIdentifier( (Serializable) value, session, overridingEager ); return resolveIdentifier( value, session, overridingEager );
} }
else if ( uniqueKeyPropertyName != null ) { else if ( uniqueKeyPropertyName != null ) {
return loadByUniqueKey( getAssociatedEntityName(), uniqueKeyPropertyName, value, session ); return loadByUniqueKey( getAssociatedEntityName(), uniqueKeyPropertyName, value, session );
@ -654,7 +653,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
* *
* @throws org.hibernate.HibernateException Indicates problems performing the load. * @throws org.hibernate.HibernateException Indicates problems performing the load.
*/ */
protected final Object resolveIdentifier(Serializable id, SharedSessionContractImplementor session, Boolean overridingEager) throws HibernateException { protected final Object resolveIdentifier(Object id, SharedSessionContractImplementor session, Boolean overridingEager) throws HibernateException {
boolean isProxyUnwrapEnabled = unwrapProxy && boolean isProxyUnwrapEnabled = unwrapProxy &&
getAssociatedEntityPersister( session.getFactory() ) getAssociatedEntityPersister( session.getFactory() )
@ -675,7 +674,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
return proxyOrEntity; return proxyOrEntity;
} }
protected final Object resolveIdentifier(Serializable id, SharedSessionContractImplementor session) throws HibernateException { protected final Object resolveIdentifier(Object id, SharedSessionContractImplementor session) throws HibernateException {
return resolveIdentifier( id, session, null ); return resolveIdentifier( id, session, null );
} }

View File

@ -147,9 +147,9 @@ public class ManyToOneType extends EntityType {
// out the empty value. // out the empty value.
final Object hydratedId = getIdentifierOrUniqueKeyType( session.getFactory() ) final Object hydratedId = getIdentifierOrUniqueKeyType( session.getFactory() )
.hydrate( rs, names, session, null ); .hydrate( rs, names, session, null );
final Serializable id; final Object id;
if ( hydratedId != null ) { if ( hydratedId != null ) {
id = (Serializable) getIdentifierOrUniqueKeyType( session.getFactory() ) id = getIdentifierOrUniqueKeyType( session.getFactory() )
.resolve( hydratedId, session, null ); .resolve( hydratedId, session, null );
} }
else { else {
@ -163,7 +163,7 @@ public class ManyToOneType extends EntityType {
* Register the entity as batch loadable, if enabled * Register the entity as batch loadable, if enabled
*/ */
@SuppressWarnings({ "JavaDoc" }) @SuppressWarnings({ "JavaDoc" })
private void scheduleBatchLoadIfNeeded(Serializable id, SharedSessionContractImplementor session) throws MappingException { private void scheduleBatchLoadIfNeeded(Object id, SharedSessionContractImplementor session) throws MappingException {
//cannot batch fetch by unique key (property-ref associations) //cannot batch fetch by unique key (property-ref associations)
if ( uniqueKeyPropertyName == null && id != null ) { if ( uniqueKeyPropertyName == null && id != null ) {
final EntityPersister persister = getAssociatedEntityPersister( session.getFactory() ); final EntityPersister persister = getAssociatedEntityPersister( session.getFactory() );
@ -258,7 +258,7 @@ public class ManyToOneType extends EntityType {
//TODO: currently broken for unique-key references (does not detect //TODO: currently broken for unique-key references (does not detect
// change to unique key property of the associated object) // change to unique key property of the associated object)
Serializable id = assembleId( oid, session ); Object id = assembleId( oid, session );
if ( id == null ) { if ( id == null ) {
return null; return null;
@ -268,9 +268,9 @@ public class ManyToOneType extends EntityType {
} }
} }
private Serializable assembleId(Serializable oid, SharedSessionContractImplementor session) { private Object assembleId(Serializable oid, SharedSessionContractImplementor session) {
//the owner of the association is not the owner of the id //the owner of the association is not the owner of the id
return ( Serializable ) getIdentifierType( session ).assemble( oid, session, null ); return getIdentifierType( session ).assemble( oid, session, null );
} }
@Override @Override

View File

@ -182,7 +182,7 @@ public class OneToOneType extends EntityType {
@Override @Override
public Object assemble(Serializable oid, SharedSessionContractImplementor session, Object owner) throws HibernateException { public Object assemble(Serializable oid, SharedSessionContractImplementor session, Object owner) throws HibernateException {
//the owner of the association is not the owner of the id //the owner of the association is not the owner of the id
Serializable id = ( Serializable ) getIdentifierType( session ).assemble( oid, session, null ); Object id = getIdentifierType( session ).assemble( oid, session, null );
if ( id == null ) { if ( id == null ) {
return null; return null;

View File

@ -36,5 +36,5 @@ public interface PrimitiveType<T> extends LiteralType<T> {
* *
* @return The default value. * @return The default value.
*/ */
public abstract Serializable getDefaultValue(); public abstract Object getDefaultValue();
} }

View File

@ -112,7 +112,7 @@ public class SpecialOneToOneType extends OneToOneType {
throws HibernateException { throws HibernateException {
//TODO: currently broken for unique-key references (does not detect //TODO: currently broken for unique-key references (does not detect
// change to unique key property of the associated object) // change to unique key property of the associated object)
Serializable id = (Serializable) getIdentifierType(session).assemble(oid, session, null); //the owner of the association is not the owner of the id Object id = getIdentifierType(session).assemble(oid, session, null); //the owner of the association is not the owner of the id
if (id==null) { if (id==null) {
return null; return null;