mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 20:24:46 +00:00
HHH-18490 Handle "concrete" generic embeddable attributes defined in mapped superclass
Also, resolve the correct expressible for function return type resolvers based on argument types.
This commit is contained in:
parent
02550618ca
commit
364fe49e55
@ -26,6 +26,7 @@
|
||||
import org.hibernate.internal.HEMLogging;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.internal.util.collections.JoinedList;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.MappedSuperclass;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
@ -60,6 +61,8 @@
|
||||
import jakarta.persistence.metamodel.SingularAttribute;
|
||||
import jakarta.persistence.metamodel.Type;
|
||||
|
||||
import static org.hibernate.internal.util.StringHelper.root;
|
||||
|
||||
/**
|
||||
* Defines a context for storing information during the building of the {@link MappingMetamodelImpl}.
|
||||
* <p>
|
||||
@ -415,7 +418,16 @@ else if ( MappedSuperclass.class.isAssignableFrom( mapping.getClass() ) ) {
|
||||
final PersistentAttribute<Object, ?> attribute =
|
||||
attributeFactory.buildAttribute( (ManagedDomainType<Object>) embeddable, property );
|
||||
if ( attribute != null ) {
|
||||
addAttribute( embeddable, attribute );
|
||||
final Property superclassProperty = getMappedSuperclassProperty(
|
||||
property.getName(),
|
||||
component.getMappedSuperclass()
|
||||
);
|
||||
if ( superclassProperty != null && superclassProperty.isGeneric() ) {
|
||||
( (AttributeContainer<Object>) embeddable ).getInFlightAccess().addConcreteGenericAttribute( attribute );
|
||||
}
|
||||
else {
|
||||
addAttribute( embeddable, attribute );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,6 +655,32 @@ private MappedSuperclass getMappedSuperclass(MappedSuperclass mappedSuperclass)
|
||||
: getMappedSuperclass( mappedSuperclass.getSuperPersistentClass() );
|
||||
}
|
||||
|
||||
private Property getMappedSuperclassProperty(String propertyName, MappedSuperclass mappedSuperclass) {
|
||||
if ( mappedSuperclass == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for ( Property property : mappedSuperclass.getDeclaredProperties() ) {
|
||||
if ( property.getName().equals( propertyName ) ) {
|
||||
return property;
|
||||
}
|
||||
}
|
||||
|
||||
final Property property = getMappedSuperclassProperty(
|
||||
propertyName,
|
||||
mappedSuperclass.getSuperMappedSuperclass()
|
||||
);
|
||||
if ( property != null ) {
|
||||
return property;
|
||||
}
|
||||
|
||||
if ( mappedSuperclass.getSuperPersistentClass() != null ) {
|
||||
return mappedSuperclass.getSuperPersistentClass().getProperty( propertyName );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private <X> Set<SingularPersistentAttribute<? super X, ?>> buildIdClassAttributes(
|
||||
IdentifiableDomainType<X> ownerType,
|
||||
List<Property> properties) {
|
||||
|
@ -241,13 +241,8 @@ else if ( !(specifiedArgType instanceof ReturnableType) ) {
|
||||
}
|
||||
|
||||
private static SqmExpressible<?> getArgumentExpressible(SqmTypedNode<?> specifiedArgument) {
|
||||
final SqmExpressible<?> expressible = specifiedArgument.getNodeType();
|
||||
final SqmExpressible<?> specifiedArgType = expressible instanceof SqmTypedNode<?>
|
||||
? ( (SqmTypedNode<?>) expressible ).getNodeType()
|
||||
: expressible;
|
||||
return specifiedArgType instanceof SqmPathSource
|
||||
? ( (SqmPathSource<?>) specifiedArgType ).getSqmPathType()
|
||||
: specifiedArgType;
|
||||
final SqmExpressible<?> expressible = specifiedArgument.getExpressible();
|
||||
return expressible != null ? expressible.getSqmType() : null;
|
||||
}
|
||||
|
||||
public static JdbcMapping extractArgumentJdbcMapping(
|
||||
|
Loading…
x
Reference in New Issue
Block a user