Make sure the SerializableJavaTypeDescriptor is never used for entities. Fix a wrong JDBC mapping causing problems converted attributes. Force IMMEDIATE fetch timing for many-to-one associations with NotFound.IGNORE
This commit is contained in:
parent
5da81c2263
commit
7b58e700db
|
@ -260,7 +260,7 @@ public class AttributeFactory {
|
|||
|
||||
final JavaTypeDescriptorRegistry registry = context.getTypeConfiguration()
|
||||
.getJavaTypeDescriptorRegistry();
|
||||
final JavaTypeDescriptor<Y> javaTypeDescriptor = registry.resolveDescriptor( embeddableClass );
|
||||
final JavaTypeDescriptor<Y> javaTypeDescriptor = registry.resolveManagedTypeDescriptor( embeddableClass );
|
||||
|
||||
embeddableType = new EmbeddableTypeImpl<>(
|
||||
javaTypeDescriptor,
|
||||
|
|
|
@ -88,7 +88,7 @@ public class EntityRepresentationStrategyPojoStandard implements EntityRepresent
|
|||
.getJavaTypeDescriptorRegistry();
|
||||
|
||||
final Class<?> mappedJavaType = bootDescriptor.getMappedClass();
|
||||
this.mappedJtd = jtdRegistry.getDescriptor( mappedJavaType );
|
||||
this.mappedJtd = jtdRegistry.resolveManagedTypeDescriptor( mappedJavaType );
|
||||
|
||||
final Class<?> proxyJavaType = bootDescriptor.getProxyInterface();
|
||||
if ( proxyJavaType != null ) {
|
||||
|
|
|
@ -424,7 +424,7 @@ public class MetadataContext {
|
|||
final JavaTypeDescriptorRegistry registry = getTypeConfiguration()
|
||||
.getJavaTypeDescriptorRegistry();
|
||||
final Class<?> componentClass = identifier.getComponentClass();
|
||||
final JavaTypeDescriptor<?> javaTypeDescriptor = registry.resolveDescriptor( componentClass );
|
||||
final JavaTypeDescriptor<?> javaTypeDescriptor = registry.resolveManagedTypeDescriptor( componentClass );
|
||||
|
||||
final EmbeddableRepresentationStrategy representationStrategy = getTypeConfiguration()
|
||||
.getMetadataBuildingContext()
|
||||
|
|
|
@ -144,7 +144,7 @@ public class BasicAttributeMapping
|
|||
selectableMapping.getCustomReadExpression(),
|
||||
selectableMapping.getCustomWriteExpression(),
|
||||
valueConverter,
|
||||
selectableMapping.getJdbcMapping(),
|
||||
original.getJdbcMapping(),
|
||||
declaringType,
|
||||
propertyAccess,
|
||||
valueGeneration
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.hibernate.mapping.Collection;
|
|||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.IndexedCollection;
|
||||
import org.hibernate.mapping.KeyValue;
|
||||
import org.hibernate.mapping.ManyToOne;
|
||||
import org.hibernate.mapping.OneToMany;
|
||||
import org.hibernate.mapping.OneToOne;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
|
@ -1509,8 +1510,9 @@ public class MappingModelCreationHelper {
|
|||
final FetchTiming fetchTiming;
|
||||
|
||||
if ( fetchStyle == FetchStyle.JOIN
|
||||
|| ( value instanceof OneToOne && value.isNullable() )
|
||||
|| !( value ).isLazy() ) {
|
||||
|| !value.isLazy()
|
||||
|| value instanceof OneToOne && value.isNullable()
|
||||
|| value instanceof ManyToOne && value.isNullable() && ( (ManyToOne) value ).isIgnoreNotFound() ) {
|
||||
fetchTiming = FetchTiming.IMMEDIATE;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -583,7 +583,7 @@ public class JpaMetamodelImpl implements JpaMetamodel {
|
|||
else {
|
||||
javaTypeDescriptor = context.getTypeConfiguration()
|
||||
.getJavaTypeDescriptorRegistry()
|
||||
.getDescriptor( javaType );
|
||||
.resolveManagedTypeDescriptor( javaType );
|
||||
}
|
||||
|
||||
final EntityTypeImpl<?> entityType = new EntityTypeImpl(
|
||||
|
@ -636,10 +636,10 @@ public class JpaMetamodelImpl implements JpaMetamodel {
|
|||
? null
|
||||
: locateOrBuildEntityType( superPersistentClass, context, typeConfiguration );
|
||||
}
|
||||
final JavaTypeDescriptor javaTypeDescriptor = context.getTypeConfiguration()
|
||||
final JavaTypeDescriptor<?> javaTypeDescriptor = context.getTypeConfiguration()
|
||||
.getJavaTypeDescriptorRegistry()
|
||||
.getDescriptor( mappedSuperclass.getMappedClass() );
|
||||
final MappedSuperclassTypeImpl mappedSuperclassType = new MappedSuperclassTypeImpl(
|
||||
.resolveManagedTypeDescriptor( mappedSuperclass.getMappedClass() );
|
||||
final MappedSuperclassTypeImpl<?> mappedSuperclassType = new MappedSuperclassTypeImpl(
|
||||
javaTypeDescriptor,
|
||||
mappedSuperclass,
|
||||
superType,
|
||||
|
|
|
@ -159,6 +159,40 @@ public class JavaTypeDescriptorRegistry implements JavaTypeDescriptorBaseline.Ba
|
|||
);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <J> JavaTypeDescriptor<J> resolveManagedTypeDescriptor(Type javaType) {
|
||||
return resolveDescriptor(
|
||||
javaType,
|
||||
() -> {
|
||||
final Class<J> javaTypeClass;
|
||||
if ( javaType instanceof Class<?> ) {
|
||||
javaTypeClass = (Class<J>) javaType;
|
||||
}
|
||||
else {
|
||||
final ParameterizedType parameterizedType = (ParameterizedType) javaType;
|
||||
javaTypeClass = (Class<J>) parameterizedType.getRawType();
|
||||
}
|
||||
final MutabilityPlan<J> mutabilityPlan;
|
||||
final MutabilityPlan<J> determinedPlan = RegistryHelper.INSTANCE.determineMutabilityPlan(
|
||||
javaType,
|
||||
typeConfiguration
|
||||
);
|
||||
if ( determinedPlan != null ) {
|
||||
mutabilityPlan = determinedPlan;
|
||||
}
|
||||
else {
|
||||
mutabilityPlan = new MutableMutabilityPlan<J>() {
|
||||
@Override
|
||||
protected J deepCopyNotNull(J value) {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}
|
||||
return new JavaTypeDescriptorBasicAdaptor<>( javaTypeClass, mutabilityPlan );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public JavaTypeDescriptor<?> resolveDynamicEntityDescriptor(String typeName) {
|
||||
return new DynamicModelJtd();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue