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