@@ -706,12 +706,10 @@ void CreateFromJoinElement(
706
706
// 2) an entity-join (join com.acme.User)
707
707
//
708
708
// so make the proper interpretation here...
709
- var entityJoinReferencedPersister = ResolveEntityJoinReferencedPersister ( path ) ;
710
- if ( entityJoinReferencedPersister != null )
709
+ // DOT node processing was moved to prefer implicit join path before probing for entity join
710
+ if ( path . Type == IDENT )
711
711
{
712
- var entityJoin = CreateEntityJoin ( entityJoinReferencedPersister , alias , joinType , with ) ;
713
- ( ( FromReferenceNode ) path ) . FromElement = entityJoin ;
714
- SetPropertyFetch ( entityJoin , propertyFetch , alias ) ;
712
+ ProcessAsEntityJoin ( ) ;
715
713
return ;
716
714
}
717
715
// The path AST should be a DotNode, and it should have been evaluated already.
@@ -729,6 +727,7 @@ void CreateFromJoinElement(
729
727
730
728
// Generate an explicit join for the root dot node. The implied joins will be collected and passed up
731
729
// to the root dot node.
730
+ dot . SkipSemiResolve = true ;
732
731
dot . Resolve ( true , false , alias == null ? null : alias . Text ) ;
733
732
734
733
FromElement fromElement ;
@@ -742,7 +741,8 @@ void CreateFromJoinElement(
742
741
fromElement = dot . GetImpliedJoin ( ) ;
743
742
if ( fromElement == null )
744
743
{
745
- throw new InvalidPathException ( "Invalid join: " + dot . Path ) ;
744
+ ProcessAsEntityJoin ( ) ;
745
+ return ;
746
746
}
747
747
SetPropertyFetch ( fromElement , propertyFetch , alias ) ;
748
748
@@ -766,6 +766,15 @@ void CreateFromJoinElement(
766
766
{
767
767
log . Debug ( "createFromJoinElement() : {0}" , _printer . ShowAsString ( fromElement , "-- join tree --" ) ) ;
768
768
}
769
+
770
+ void ProcessAsEntityJoin ( )
771
+ {
772
+ var node = ( FromReferenceNode ) path ;
773
+ var entityJoinReferencedPersister = ResolveEntityJoinReferencedPersister ( node ) ;
774
+ var entityJoin = CreateEntityJoin ( entityJoinReferencedPersister , alias , joinType , with ) ;
775
+ node . FromElement = entityJoin ;
776
+ SetPropertyFetch ( entityJoin , propertyFetch , alias ) ;
777
+ }
769
778
}
770
779
771
780
private EntityJoinFromElement CreateEntityJoin (
@@ -794,42 +803,29 @@ private EntityJoinFromElement CreateEntityJoin(
794
803
return join ;
795
804
}
796
805
797
- private IQueryable ResolveEntityJoinReferencedPersister ( IASTNode path )
806
+ private IQueryable ResolveEntityJoinReferencedPersister ( FromReferenceNode path )
798
807
{
799
- string entityName = GetEntityJoinCandidateEntityName ( path ) ;
808
+ string entityName = path . Path ;
800
809
801
810
var persister = SessionFactoryHelper . FindQueryableUsingImports ( entityName ) ;
802
811
if ( persister == null && entityName != null )
803
812
{
804
813
var implementors = SessionFactoryHelper . Factory . GetImplementors ( entityName ) ;
805
814
//Possible case - join on interface
806
815
if ( implementors . Length == 1 )
807
- persister = SessionFactoryHelper . FindQueryableUsingImports ( implementors [ 0 ] ) ;
816
+ persister = ( IQueryable ) SessionFactoryHelper . Factory . TryGetEntityPersister ( implementors [ 0 ] ) ;
808
817
}
809
818
810
819
if ( persister != null )
811
820
return persister ;
812
821
813
822
if ( path . Type == IDENT )
814
823
{
815
- // Since IDENT node is not expected for implicit join path, we can throw on not found persister
816
824
throw new QuerySyntaxException ( entityName + " is not mapped" ) ;
817
825
}
818
826
819
- return null ;
820
- }
821
-
822
- private static string GetEntityJoinCandidateEntityName ( IASTNode path )
823
- {
824
- switch ( path . Type )
825
- {
826
- case IDENT :
827
- return ( ( IdentNode ) path ) . Path ;
828
- case DOT :
829
- return ASTUtil . GetPathText ( path ) ;
830
- }
831
-
832
- return null ;
827
+ //Keep old exception for DOT node
828
+ throw new InvalidPathException ( "Invalid join: " + entityName ) ;
833
829
}
834
830
835
831
private static string GetPropertyPath ( DotNode dotNode , IASTNode alias )
0 commit comments