mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
Allow ast navigation embedded > to-one
This commit is contained in:
parent
4e216a121c
commit
de0dffe105
@ -10,6 +10,7 @@
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.mapping.internal.AbstractDomainPath;
|
||||
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.ordering.TranslationContext;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
|
||||
@ -64,9 +65,26 @@ public SequencePart resolvePathPart(
|
||||
subPart
|
||||
);
|
||||
}
|
||||
if ( referencedModelPart instanceof ToOneAttributeMapping ) {
|
||||
ToOneAttributeMapping toOneAttribute = (ToOneAttributeMapping) referencedModelPart;
|
||||
if ( name.equals( toOneAttribute.getTargetKeyPropertyName() ) ) {
|
||||
final ModelPart subPart = toOneAttribute.findSubPart( name );
|
||||
if ( subPart == null ) {
|
||||
throw new PathResolutionException(
|
||||
"Could not resolve path token : " + referencedModelPart + " -> " + name
|
||||
);
|
||||
}
|
||||
|
||||
return new DomainPathContinuation(
|
||||
navigablePath.append( name ),
|
||||
this,
|
||||
subPart
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
throw new PathResolutionException(
|
||||
"Domain path of type `" + referencedModelPart.getPartMappingType() +
|
||||
"Domain path of type `" + referencedModelPart.getPartMappingType() +
|
||||
"` -> `" + name + "`"
|
||||
);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.AbstractDomainPath;
|
||||
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.ordering.TranslationContext;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
|
||||
@ -55,7 +56,7 @@ public DomainPath resolvePathPart(
|
||||
if ( subPart instanceof CollectionPart ) {
|
||||
return new CollectionPartPath( this, (CollectionPart) subPart );
|
||||
}
|
||||
else if ( !( subPart instanceof EmbeddableValuedModelPart ) ) {
|
||||
else if ( !( subPart instanceof EmbeddableValuedModelPart || subPart instanceof ToOneAttributeMapping ) ) {
|
||||
final CollectionPartPath elementPath = new CollectionPartPath(
|
||||
this,
|
||||
pluralAttributeMapping.getElementDescriptor()
|
||||
|
Loading…
x
Reference in New Issue
Block a user