HHH-17460 - Ongoing JPA 32 work
* Fix binding of `@IdClass` with generic property on the entity side * Small cleanups to generics logic
This commit is contained in:
parent
46cb96c35d
commit
6260941790
|
@ -382,15 +382,15 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
|
|||
ClassDetails classDetails,
|
||||
String accessType,
|
||||
Map<String, MemberDetails> members) {
|
||||
final List<MemberDetails> collectedMembers = new ArrayList<>( switch ( accessType ) {
|
||||
final List<? extends MemberDetails> collectedMembers = switch ( accessType ) {
|
||||
case ACCESS_FIELD -> classDetails.getFields();
|
||||
case ACCESS_PROPERTY -> classDetails.getMethods();
|
||||
case ACCESS_RECORD -> classDetails.getRecordComponents();
|
||||
default -> throw new IllegalArgumentException( "Unknown access type " + accessType );
|
||||
} );
|
||||
members.putAll( collectedMembers.stream()
|
||||
.filter( MemberDetails::isPersistable )
|
||||
.collect( Collectors.toMap( MemberDetails::resolveAttributeName, item -> item ) ) );
|
||||
};
|
||||
collectedMembers.stream()
|
||||
.filter( MemberDetails::isPersistable )
|
||||
.forEach( member -> members.put( member.resolveAttributeName(), member ) );
|
||||
}
|
||||
|
||||
private static void setTypeName(Value value, String typeName) {
|
||||
|
|
|
@ -316,6 +316,7 @@ public class EmbeddableBinder {
|
|||
inferredData,
|
||||
null,
|
||||
propertyAccessor,
|
||||
null,
|
||||
isNullable,
|
||||
entityBinder,
|
||||
isComponentEmbedded,
|
||||
|
@ -335,6 +336,7 @@ public class EmbeddableBinder {
|
|||
PropertyData inferredData,
|
||||
PropertyData baseInferredData, //base inferred data correspond to the entity reproducing inferredData's properties (ie IdClass)
|
||||
AccessType propertyAccessor,
|
||||
ClassDetails entityAtStake,
|
||||
boolean isNullable,
|
||||
EntityBinder entityBinder,
|
||||
boolean isComponentEmbedded,
|
||||
|
@ -438,7 +440,7 @@ public class EmbeddableBinder {
|
|||
}
|
||||
|
||||
final List<PropertyData> baseClassElements =
|
||||
collectBaseClassElements( baseInferredData, propertyAccessor, context, annotatedType );
|
||||
collectBaseClassElements( baseInferredData, propertyAccessor, context, entityAtStake );
|
||||
if ( baseClassElements != null
|
||||
//useful to avoid breaking pre JPA 2 mappings
|
||||
&& !hasAnnotationsOnIdClass( annotatedType ) ) {
|
||||
|
@ -729,7 +731,7 @@ public class EmbeddableBinder {
|
|||
PropertyData baseInferredData,
|
||||
AccessType propertyAccessor,
|
||||
MetadataBuildingContext context,
|
||||
TypeDetails annotatedClass) {
|
||||
ClassDetails entityAtStake) {
|
||||
if ( baseInferredData != null ) {
|
||||
final List<PropertyData> baseClassElements = new ArrayList<>();
|
||||
// iterate from base returned class up hierarchy to handle cases where the @Id attributes
|
||||
|
@ -738,7 +740,7 @@ public class EmbeddableBinder {
|
|||
while ( !Object.class.getName().equals( baseReturnedClassOrElement.getName() ) ) {
|
||||
final PropertyContainer container = new PropertyContainer(
|
||||
baseReturnedClassOrElement.determineRawClass(),
|
||||
annotatedClass,
|
||||
entityAtStake,
|
||||
propertyAccessor
|
||||
);
|
||||
addElementsOfClass( baseClassElements, container, context );
|
||||
|
|
|
@ -598,6 +598,7 @@ public class EntityBinder {
|
|||
),
|
||||
baseInferredData,
|
||||
propertyAccessor,
|
||||
annotatedClass,
|
||||
false,
|
||||
this,
|
||||
true,
|
||||
|
@ -696,6 +697,7 @@ public class EntityBinder {
|
|||
inferredData,
|
||||
baseInferredData,
|
||||
propertyAccessor,
|
||||
annotatedClass,
|
||||
false,
|
||||
this,
|
||||
true,
|
||||
|
|
|
@ -106,7 +106,7 @@ public class PropertyInferredData implements PropertyData {
|
|||
return new ClassTypeDetailsImpl( legacyAnnotationUsage.getClassDetails( "value" ), TypeDetails.Kind.CLASS );
|
||||
}
|
||||
|
||||
return propertyMember.getAssociatedType().determineRelativeType( ownerType );
|
||||
return propertyMember.resolveRelativeAssociatedType( ownerType );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue