@@ -15,7 +15,7 @@ namespace NHibernate.Impl
15
15
/// Implementation of the <see cref="ICriteria"/> interface
16
16
/// </summary>
17
17
[ Serializable ]
18
- public partial class CriteriaImpl : ICriteria
18
+ public partial class CriteriaImpl : ICriteria , ISupportEntityJoinCriteria
19
19
{
20
20
private readonly System . Type persistentClass ;
21
21
private readonly List < CriterionEntry > criteria = new List < CriterionEntry > ( ) ;
@@ -42,6 +42,9 @@ public partial class CriteriaImpl : ICriteria
42
42
43
43
private readonly Dictionary < string , ICriteria > subcriteriaByPath = new Dictionary < string , ICriteria > ( ) ;
44
44
private readonly Dictionary < string , ICriteria > subcriteriaByAlias = new Dictionary < string , ICriteria > ( ) ;
45
+
46
+ private readonly Dictionary < string , string > entityJoinAliasToEntityNameMap = new Dictionary < string , string > ( ) ;
47
+
45
48
private readonly string entityOrClassName ;
46
49
47
50
// Projection Fields
@@ -71,6 +74,11 @@ public CriteriaImpl(string entityOrClassName, string alias, ISessionImplementor
71
74
rootAlias = alias ;
72
75
subcriteriaByAlias [ alias ] = this ;
73
76
}
77
+
78
+ public IDictionary < string , string > GetEntityJoinAliasToEntityNameMap ( )
79
+ {
80
+ return entityJoinAliasToEntityNameMap ;
81
+ }
74
82
75
83
public ISessionImplementor Session
76
84
{
@@ -371,6 +379,11 @@ public ICriteria CreateAlias(string associationPath, string alias, JoinType join
371
379
return this ;
372
380
}
373
381
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
+
374
387
public ICriteria Add ( ICriteria criteriaInst , ICriterion expression )
375
388
{
376
389
criteria . Add ( new CriterionEntry ( expression , criteriaInst ) ) ;
@@ -647,18 +660,23 @@ public sealed partial class Subcriteria : ICriteria
647
660
private readonly JoinType joinType ;
648
661
private ICriterion withClause ;
649
662
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 )
651
664
{
652
665
this . root = root ;
653
666
this . parent = parent ;
654
667
this . alias = alias ;
655
668
this . path = path ;
656
669
this . joinType = joinType ;
657
670
this . withClause = withClause ;
671
+ JoinEntityName = joinEntityName ;
658
672
659
673
root . subcriteriaList . Add ( this ) ;
660
674
661
- root . subcriteriaByPath [ path ] = this ;
675
+ if ( JoinEntityName == null )
676
+ root . subcriteriaByPath [ path ] = this ;
677
+ else
678
+ root . entityJoinAliasToEntityNameMap [ alias ] = JoinEntityName ;
679
+
662
680
SetAlias ( alias ) ;
663
681
}
664
682
@@ -668,6 +686,16 @@ internal Subcriteria(CriteriaImpl root, ICriteria parent, string path, string al
668
686
internal Subcriteria ( CriteriaImpl root , ICriteria parent , string path , JoinType joinType )
669
687
: this ( root , parent , path , null , joinType ) { }
670
688
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
+
671
699
public ICriterion WithClause
672
700
{
673
701
get { return withClause ; }
0 commit comments