Allow ast navigation embedded > to-one
This commit is contained in:
parent
4e216a121c
commit
de0dffe105
|
@ -10,6 +10,7 @@ import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
|||
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,6 +65,23 @@ public class DomainPathContinuation extends AbstractDomainPath {
|
|||
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() +
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
|||
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 class PluralAttributePath extends AbstractDomainPath {
|
|||
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…
Reference in New Issue