HHH-16664 NPE in MappingMetamodelImpl if inheritance is used in IdClass
This commit is contained in:
parent
0147541b1c
commit
e7fa3cebb6
|
@ -298,7 +298,8 @@ public class EmbeddableBinder {
|
||||||
compositeUserTypeClass,
|
compositeUserTypeClass,
|
||||||
columns,
|
columns,
|
||||||
context,
|
context,
|
||||||
inheritanceStatePerClass
|
inheritanceStatePerClass,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +317,8 @@ public class EmbeddableBinder {
|
||||||
Class<? extends CompositeUserType<?>> compositeUserTypeClass,
|
Class<? extends CompositeUserType<?>> compositeUserTypeClass,
|
||||||
AnnotatedColumns columns,
|
AnnotatedColumns columns,
|
||||||
MetadataBuildingContext context,
|
MetadataBuildingContext context,
|
||||||
Map<XClass, InheritanceState> inheritanceStatePerClass) {
|
Map<XClass, InheritanceState> inheritanceStatePerClass,
|
||||||
|
boolean isIdClass) {
|
||||||
// inSecondPass can only be used to apply right away the second pass of a composite-element
|
// inSecondPass can only be used to apply right away the second pass of a composite-element
|
||||||
// Because it's a value type, there is no bidirectional association, hence second pass
|
// Because it's a value type, there is no bidirectional association, hence second pass
|
||||||
// ordering does not matter
|
// ordering does not matter
|
||||||
|
@ -358,7 +360,7 @@ public class EmbeddableBinder {
|
||||||
|
|
||||||
final XClass annotatedClass = inferredData.getPropertyClass();
|
final XClass annotatedClass = inferredData.getPropertyClass();
|
||||||
final List<PropertyData> classElements =
|
final List<PropertyData> classElements =
|
||||||
collectClassElements( propertyAccessor, context, returnedClassOrElement, annotatedClass );
|
collectClassElements( propertyAccessor, context, returnedClassOrElement, annotatedClass, isIdClass );
|
||||||
final List<PropertyData> baseClassElements =
|
final List<PropertyData> baseClassElements =
|
||||||
collectBaseClassElements( baseInferredData, propertyAccessor, context, annotatedClass );
|
collectBaseClassElements( baseInferredData, propertyAccessor, context, annotatedClass );
|
||||||
if ( baseClassElements != null
|
if ( baseClassElements != null
|
||||||
|
@ -421,7 +423,8 @@ public class EmbeddableBinder {
|
||||||
AccessType propertyAccessor,
|
AccessType propertyAccessor,
|
||||||
MetadataBuildingContext context,
|
MetadataBuildingContext context,
|
||||||
XClass returnedClassOrElement,
|
XClass returnedClassOrElement,
|
||||||
XClass annotatedClass) {
|
XClass annotatedClass,
|
||||||
|
boolean isIdClass) {
|
||||||
final List<PropertyData> classElements = new ArrayList<>();
|
final List<PropertyData> classElements = new ArrayList<>();
|
||||||
//embeddable elements can have type defs
|
//embeddable elements can have type defs
|
||||||
final PropertyContainer container =
|
final PropertyContainer container =
|
||||||
|
@ -429,7 +432,8 @@ public class EmbeddableBinder {
|
||||||
addElementsOfClass( classElements, container, context);
|
addElementsOfClass( classElements, container, context);
|
||||||
//add elements of the embeddable's mapped superclasses
|
//add elements of the embeddable's mapped superclasses
|
||||||
XClass superClass = annotatedClass.getSuperclass();
|
XClass superClass = annotatedClass.getSuperclass();
|
||||||
while ( superClass != null && superClass.isAnnotationPresent( MappedSuperclass.class ) ) {
|
while ( superClass != null && ( superClass.isAnnotationPresent( MappedSuperclass.class )
|
||||||
|
|| ( isIdClass && !Object.class.getName().equals( superClass.getName() ) ) ) ) {
|
||||||
//FIXME: proper support of type variables incl var resolved at upper levels
|
//FIXME: proper support of type variables incl var resolved at upper levels
|
||||||
final PropertyContainer superContainer =
|
final PropertyContainer superContainer =
|
||||||
new PropertyContainer( superClass, annotatedClass, propertyAccessor );
|
new PropertyContainer( superClass, annotatedClass, propertyAccessor );
|
||||||
|
|
|
@ -405,7 +405,8 @@ public class EntityBinder {
|
||||||
classWithIdClass,
|
classWithIdClass,
|
||||||
compositeClass,
|
compositeClass,
|
||||||
baseInferredData,
|
baseInferredData,
|
||||||
propertyAccessor
|
propertyAccessor,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
setIgnoreIdAnnotations( ignoreIdAnnotations );
|
setIgnoreIdAnnotations( ignoreIdAnnotations );
|
||||||
for ( Property property : mapper.getProperties() ) {
|
for ( Property property : mapper.getProperties() ) {
|
||||||
|
@ -427,7 +428,8 @@ public class EntityBinder {
|
||||||
XClass classWithIdClass,
|
XClass classWithIdClass,
|
||||||
XClass compositeClass,
|
XClass compositeClass,
|
||||||
PropertyData baseInferredData,
|
PropertyData baseInferredData,
|
||||||
AccessType propertyAccessor) {
|
AccessType propertyAccessor,
|
||||||
|
boolean isIdClass) {
|
||||||
final Component mapper = createMapper(
|
final Component mapper = createMapper(
|
||||||
inheritanceStates,
|
inheritanceStates,
|
||||||
persistentClass,
|
persistentClass,
|
||||||
|
@ -436,7 +438,8 @@ public class EntityBinder {
|
||||||
classWithIdClass,
|
classWithIdClass,
|
||||||
compositeClass,
|
compositeClass,
|
||||||
baseInferredData,
|
baseInferredData,
|
||||||
propertyAccessor
|
propertyAccessor,
|
||||||
|
isIdClass
|
||||||
);
|
);
|
||||||
final Property mapperProperty = new Property();
|
final Property mapperProperty = new Property();
|
||||||
mapperProperty.setName( NavigablePath.IDENTIFIER_MAPPER_PROPERTY );
|
mapperProperty.setName( NavigablePath.IDENTIFIER_MAPPER_PROPERTY );
|
||||||
|
@ -456,7 +459,8 @@ public class EntityBinder {
|
||||||
XClass classWithIdClass,
|
XClass classWithIdClass,
|
||||||
XClass compositeClass,
|
XClass compositeClass,
|
||||||
PropertyData baseInferredData,
|
PropertyData baseInferredData,
|
||||||
AccessType propertyAccessor) {
|
AccessType propertyAccessor,
|
||||||
|
boolean isIdClass) {
|
||||||
final Component mapper = fillEmbeddable(
|
final Component mapper = fillEmbeddable(
|
||||||
propertyHolder,
|
propertyHolder,
|
||||||
new PropertyPreloadedData(
|
new PropertyPreloadedData(
|
||||||
|
@ -475,7 +479,8 @@ public class EntityBinder {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
context,
|
context,
|
||||||
inheritanceStates
|
inheritanceStates,
|
||||||
|
isIdClass
|
||||||
);
|
);
|
||||||
persistentClass.setIdentifierMapper( mapper );
|
persistentClass.setIdentifierMapper( mapper );
|
||||||
|
|
||||||
|
@ -575,7 +580,8 @@ public class EntityBinder {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
buildingContext,
|
buildingContext,
|
||||||
inheritanceStates
|
inheritanceStates,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
id.setKey( true );
|
id.setKey( true );
|
||||||
if ( rootClass.getIdentifier() != null ) {
|
if ( rootClass.getIdentifier() != null ) {
|
||||||
|
|
Loading…
Reference in New Issue