fill in type parameters of raw type in Type interface

This commit is contained in:
Gavin King 2022-01-30 18:09:44 +01:00
parent 1b0862babd
commit 5b5c76abfd
12 changed files with 39 additions and 27 deletions

View File

@ -172,7 +172,7 @@ public class DiscriminatorType<T> extends AbstractType implements BasicType<T>,
} }
@Override @Override
public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map copyCache) public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object, Object> copyCache)
throws HibernateException { throws HibernateException {
return original; return original;
} }

View File

@ -254,7 +254,7 @@ public abstract class AbstractStandardBasicType<T>
@Override @Override
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked" })
public final Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map copyCache) { public final Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object, Object> copyCache) {
if ( original == null && target == null ) { if ( original == null && target == null ) {
return null; return null;
} }
@ -269,7 +269,7 @@ public abstract class AbstractStandardBasicType<T>
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache, Map<Object, Object> copyCache,
ForeignKeyDirection foreignKeyDirection) { ForeignKeyDirection foreignKeyDirection) {
return ForeignKeyDirection.FROM_PARENT == foreignKeyDirection return ForeignKeyDirection.FROM_PARENT == foreignKeyDirection
? javaType.getReplacement( (T) original, (T) target, session ) ? javaType.getReplacement( (T) original, (T) target, session )

View File

@ -119,7 +119,7 @@ public abstract class AbstractType implements Type {
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache, Map<Object, Object> copyCache,
ForeignKeyDirection foreignKeyDirection) ForeignKeyDirection foreignKeyDirection)
throws HibernateException { throws HibernateException {
boolean include; boolean include;

View File

@ -301,7 +301,7 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
} }
@Override @Override
public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map copyCache) public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object, Object> copyCache)
throws HibernateException { throws HibernateException {
if ( original == null ) { if ( original == null ) {
return null; return null;

View File

@ -651,7 +651,7 @@ public abstract class CollectionType extends AbstractType implements Association
final Object target, final Object target,
final SharedSessionContractImplementor session, final SharedSessionContractImplementor session,
final Object owner, final Object owner,
final Map copyCache) throws HibernateException { final Map<Object, Object> copyCache) throws HibernateException {
if ( original == null ) { if ( original == null ) {
return null; return null;
} }

View File

@ -12,7 +12,6 @@ import java.sql.CallableStatement;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
@ -483,7 +482,7 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache) { Map<Object, Object> copyCache) {
if ( original == null ) { if ( original == null ) {
return null; return null;
@ -527,7 +526,7 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache, Map<Object, Object> copyCache,
ForeignKeyDirection foreignKeyDirection) { ForeignKeyDirection foreignKeyDirection) {
if ( original == null ) { if ( original == null ) {

View File

@ -158,7 +158,7 @@ public class CustomType<J>
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache) throws HibernateException { Map<Object, Object> copyCache) throws HibernateException {
return getUserType().replace( original, target, owner ); return getUserType().replace( original, target, owner );
} }

View File

@ -269,7 +269,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache) throws HibernateException { Map<Object, Object> copyCache) throws HibernateException {
if ( original == null ) { if ( original == null ) {
return null; return null;
} }
@ -404,7 +404,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
* @param overridingEager can override eager from the mapping. * @param overridingEager can override eager from the mapping.
* *
* @return If {@code overridingEager} is null, then it does not override. * @return If {@code overridingEager} is null, then it does not override.
* If true or false then it overrides the mapping value. * If true or false then it overrides the mapping value.
*/ */
public boolean isEager(Boolean overridingEager) { public boolean isEager(Boolean overridingEager) {
return overridingEager != null ? overridingEager : this.eager; return overridingEager != null ? overridingEager : this.eager;

View File

@ -113,7 +113,7 @@ public class MetaType extends AbstractType {
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache) { Map<Object, Object> copyCache) {
return original; return original;
} }

View File

@ -308,7 +308,7 @@ public class SerializableToBlobType<T extends Serializable> implements BasicType
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map copyCache) { public final Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object, Object> copyCache) {
if ( original == null && target == null ) { if ( original == null && target == null ) {
return null; return null;
} }
@ -317,13 +317,13 @@ public class SerializableToBlobType<T extends Serializable> implements BasicType
} }
@Override @Override
@SuppressWarnings({ "unchecked" }) // @SuppressWarnings({ "unchecked" })
public Object replace( public Object replace(
Object original, Object original,
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache, Map<Object, Object> copyCache,
ForeignKeyDirection foreignKeyDirection) { ForeignKeyDirection foreignKeyDirection) {
return ForeignKeyDirection.FROM_PARENT == foreignKeyDirection return ForeignKeyDirection.FROM_PARENT == foreignKeyDirection
? javaType.getReplacement( (T) original, (T) target, session ) ? javaType.getReplacement( (T) original, (T) target, session )

View File

@ -392,7 +392,7 @@ public interface Type extends Serializable {
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache) throws HibernateException; Map<Object, Object> copyCache) throws HibernateException;
/** /**
* During merge, replace the existing (target) value in the entity we are merging to * During merge, replace the existing (target) value in the entity we are merging to
@ -417,7 +417,7 @@ public interface Type extends Serializable {
Object target, Object target,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
Object owner, Object owner,
Map copyCache, Map<Object, Object> copyCache,
ForeignKeyDirection foreignKeyDirection) throws HibernateException; ForeignKeyDirection foreignKeyDirection) throws HibernateException;
/** /**

View File

@ -73,10 +73,11 @@ public class TypeHelper {
final Type[] types, final Type[] types,
final SharedSessionContractImplementor session, final SharedSessionContractImplementor session,
final Object owner, final Object owner,
final Map copyCache) { final Map<Object, Object> copyCache) {
Object[] copied = new Object[original.length]; Object[] copied = new Object[original.length];
for ( int i = 0; i < types.length; i++ ) { for ( int i = 0; i < types.length; i++ ) {
if ( original[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY || original[i] == PropertyAccessStrategyBackRefImpl.UNKNOWN ) { if ( original[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY
|| original[i] == PropertyAccessStrategyBackRefImpl.UNKNOWN ) {
copied[i] = target[i]; copied[i] = target[i];
} }
else if ( target[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY ) { else if ( target[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
@ -108,7 +109,7 @@ public class TypeHelper {
final Type[] types, final Type[] types,
final SharedSessionContractImplementor session, final SharedSessionContractImplementor session,
final Object owner, final Object owner,
final Map copyCache, final Map<Object, Object> copyCache,
final ForeignKeyDirection foreignKeyDirection) { final ForeignKeyDirection foreignKeyDirection) {
Object[] copied = new Object[original.length]; Object[] copied = new Object[original.length];
for ( int i = 0; i < types.length; i++ ) { for ( int i = 0; i < types.length; i++ ) {
@ -149,7 +150,7 @@ public class TypeHelper {
final Type[] types, final Type[] types,
final SharedSessionContractImplementor session, final SharedSessionContractImplementor session,
final Object owner, final Object owner,
final Map copyCache, final Map<Object, Object> copyCache,
final ForeignKeyDirection foreignKeyDirection) { final ForeignKeyDirection foreignKeyDirection) {
Object[] copied = new Object[original.length]; Object[] copied = new Object[original.length];
for ( int i = 0; i < types.length; i++ ) { for ( int i = 0; i < types.length; i++ ) {
@ -161,9 +162,21 @@ public class TypeHelper {
// need to extract the component values and check for subtype replacements... // need to extract the component values and check for subtype replacements...
CompositeType componentType = ( CompositeType ) types[i]; CompositeType componentType = ( CompositeType ) types[i];
Type[] subtypes = componentType.getSubtypes(); Type[] subtypes = componentType.getSubtypes();
Object[] origComponentValues = original[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( original[i], session ); Object[] origComponentValues = original[i] == null
Object[] targetComponentValues = target[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( target[i], session ); ? new Object[subtypes.length]
replaceAssociations( origComponentValues, targetComponentValues, subtypes, session, null, copyCache, foreignKeyDirection ); : componentType.getPropertyValues( original[i], session );
Object[] targetComponentValues = target[i] == null
? new Object[subtypes.length]
: componentType.getPropertyValues( target[i], session );
replaceAssociations(
origComponentValues,
targetComponentValues,
subtypes,
session,
null,
copyCache,
foreignKeyDirection
);
copied[i] = target[i]; copied[i] = target[i];
} }
else if ( !types[i].isAssociationType() ) { else if ( !types[i].isAssociationType() ) {