@@ -17,7 +17,11 @@ namespace NHibernate.Type
1717 [ Serializable ]
1818 public abstract partial class EntityType : AbstractType , IAssociationType
1919 {
20+ // Since v5.1
21+ [ Obsolete ( "This field has no more usages in NHibernate and will be removed. Use RHSUniqueKeyPropertyName instead." ) ]
2022 protected readonly string uniqueKeyPropertyName ;
23+
24+ private readonly string _uniqueKeyPropertyName ;
2125 private readonly bool eager ;
2226 private readonly string associatedEntityName ;
2327 private readonly bool unwrapProxy ;
@@ -37,8 +41,12 @@ public abstract partial class EntityType : AbstractType, IAssociationType
3741 /// </param>
3842 protected internal EntityType ( string entityName , string uniqueKeyPropertyName , bool eager , bool unwrapProxy )
3943 {
40- associatedEntityName = entityName ;
44+ #pragma warning disable 618
4145 this . uniqueKeyPropertyName = uniqueKeyPropertyName ;
46+ #pragma warning restore 618
47+
48+ associatedEntityName = entityName ;
49+ _uniqueKeyPropertyName = uniqueKeyPropertyName ;
4250 this . eager = eager ;
4351 this . unwrapProxy = unwrapProxy ;
4452 }
@@ -165,12 +173,12 @@ protected internal object GetReferenceValue(object value, ISessionImplementor se
165173 else
166174 {
167175 IEntityPersister entityPersister = session . Factory . GetEntityPersister ( GetAssociatedEntityName ( ) ) ;
168- object propertyValue = entityPersister . GetPropertyValue ( value , uniqueKeyPropertyName ) ;
176+ object propertyValue = entityPersister . GetPropertyValue ( value , _uniqueKeyPropertyName ) ;
169177
170178 // We now have the value of the property-ref we reference. However,
171179 // we need to dig a little deeper, as that property might also be
172180 // an entity type, in which case we need to resolve its identitifier
173- IType type = entityPersister . GetPropertyType ( uniqueKeyPropertyName ) ;
181+ IType type = entityPersister . GetPropertyType ( _uniqueKeyPropertyName ) ;
174182 if ( type . IsEntityType )
175183 {
176184 propertyValue = ( ( EntityType ) type ) . GetReferenceValue ( propertyValue , session ) ;
@@ -283,7 +291,7 @@ public override sealed object NullSafeGet(DbDataReader rs, string[] names, ISess
283291
284292 public bool IsUniqueKeyReference
285293 {
286- get { return uniqueKeyPropertyName != null ; }
294+ get { return _uniqueKeyPropertyName != null ; }
287295 }
288296
289297 public abstract bool IsNullable { get ; }
@@ -311,7 +319,7 @@ public IType GetIdentifierOrUniqueKeyType(IMapping factory)
311319 }
312320 else
313321 {
314- IType type = factory . GetReferencedPropertyType ( GetAssociatedEntityName ( ) , uniqueKeyPropertyName ) ;
322+ IType type = factory . GetReferencedPropertyType ( GetAssociatedEntityName ( ) , _uniqueKeyPropertyName ) ;
315323 if ( type . IsEntityType )
316324 {
317325 type = ( ( EntityType ) type ) . GetIdentifierOrUniqueKeyType ( factory ) ;
@@ -333,7 +341,7 @@ public string GetIdentifierOrUniqueKeyPropertyName(IMapping factory)
333341 }
334342 else
335343 {
336- return uniqueKeyPropertyName ;
344+ return _uniqueKeyPropertyName ;
337345 }
338346 }
339347
@@ -399,7 +407,7 @@ public override object ResolveIdentifier(object value, ISessionImplementor sessi
399407 }
400408 else
401409 {
402- return LoadByUniqueKey ( GetAssociatedEntityName ( ) , uniqueKeyPropertyName , value , session ) ;
410+ return LoadByUniqueKey ( GetAssociatedEntityName ( ) , _uniqueKeyPropertyName , value , session ) ;
403411 }
404412 }
405413 }
@@ -438,7 +446,7 @@ public string LHSPropertyName
438446
439447 public string RHSUniqueKeyPropertyName
440448 {
441- get { return uniqueKeyPropertyName ; }
449+ get { return _uniqueKeyPropertyName ; }
442450 }
443451
444452 public virtual string PropertyName
@@ -472,7 +480,7 @@ public override int GetHashCode(object x, ISessionFactoryImplementor factory)
472480
473481 public bool IsReferenceToPrimaryKey
474482 {
475- get { return string . IsNullOrEmpty ( uniqueKeyPropertyName ) ; }
483+ get { return string . IsNullOrEmpty ( _uniqueKeyPropertyName ) ; }
476484 }
477485
478486 public string GetOnCondition ( string alias , ISessionFactoryImplementor factory , IDictionary < string , IFilter > enabledFilters )
0 commit comments