@@ -15,7 +15,7 @@ namespace NHibernate.Impl
1515 /// Implementation of the <see cref="ICriteria"/> interface
1616 /// </summary>
1717 [ Serializable ]
18- public partial class CriteriaImpl : ICriteria
18+ public partial class CriteriaImpl : ICriteria , ISupportEntityJoinCriteria
1919 {
2020 private readonly System . Type persistentClass ;
2121 private readonly List < CriterionEntry > criteria = new List < CriterionEntry > ( ) ;
@@ -42,6 +42,9 @@ public partial class CriteriaImpl : ICriteria
4242
4343 private readonly Dictionary < string , ICriteria > subcriteriaByPath = new Dictionary < string , ICriteria > ( ) ;
4444 private readonly Dictionary < string , ICriteria > subcriteriaByAlias = new Dictionary < string , ICriteria > ( ) ;
45+
46+ private readonly Dictionary < string , string > entityJoinAliasToEntityNameMap = new Dictionary < string , string > ( ) ;
47+
4548 private readonly string entityOrClassName ;
4649
4750 // Projection Fields
@@ -71,6 +74,11 @@ public CriteriaImpl(string entityOrClassName, string alias, ISessionImplementor
7174 rootAlias = alias ;
7275 subcriteriaByAlias [ alias ] = this ;
7376 }
77+
78+ public IDictionary < string , string > GetEntityJoinAliasToEntityNameMap ( )
79+ {
80+ return entityJoinAliasToEntityNameMap ;
81+ }
7482
7583 public ISessionImplementor Session
7684 {
@@ -371,6 +379,11 @@ public ICriteria CreateAlias(string associationPath, string alias, JoinType join
371379 return this ;
372380 }
373381
382+ public ICriteria CreateEntityCriteria ( string alias , JoinType joinType , ICriterion withClause , string entityName )
383+ {
384+ return new Subcriteria ( this , this , alias , alias , joinType , withClause , entityName ) ;
385+ }
386+
374387 public ICriteria Add ( ICriteria criteriaInst , ICriterion expression )
375388 {
376389 criteria . Add ( new CriterionEntry ( expression , criteriaInst ) ) ;
@@ -647,18 +660,23 @@ public sealed partial class Subcriteria : ICriteria
647660 private readonly JoinType joinType ;
648661 private ICriterion withClause ;
649662
650- internal Subcriteria ( CriteriaImpl root , ICriteria parent , string path , string alias , JoinType joinType , ICriterion withClause )
663+ internal Subcriteria ( CriteriaImpl root , ICriteria parent , string path , string alias , JoinType joinType , ICriterion withClause , string joinEntityName = null )
651664 {
652665 this . root = root ;
653666 this . parent = parent ;
654667 this . alias = alias ;
655668 this . path = path ;
656669 this . joinType = joinType ;
657670 this . withClause = withClause ;
671+ JoinEntityName = joinEntityName ;
658672
659673 root . subcriteriaList . Add ( this ) ;
660674
661- root . subcriteriaByPath [ path ] = this ;
675+ if ( JoinEntityName == null )
676+ root . subcriteriaByPath [ path ] = this ;
677+ else
678+ root . entityJoinAliasToEntityNameMap [ alias ] = JoinEntityName ;
679+
662680 SetAlias ( alias ) ;
663681 }
664682
@@ -668,6 +686,16 @@ internal Subcriteria(CriteriaImpl root, ICriteria parent, string path, string al
668686 internal Subcriteria ( CriteriaImpl root , ICriteria parent , string path , JoinType joinType )
669687 : this ( root , parent , path , null , joinType ) { }
670688
689+ /// <summary>
690+ /// Entity name for "Entity Join" - join for enitity with not mapped association
691+ /// </summary>
692+ public string JoinEntityName { get ; }
693+
694+ /// <summary>
695+ /// Is this an Entity join for not mapped association
696+ /// </summary>
697+ public bool IsEntityJoin => JoinEntityName != null ;
698+
671699 public ICriterion WithClause
672700 {
673701 get { return withClause ; }
0 commit comments