@@ -17,8 +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 ;
2123
24+ private readonly string _uniqueKeyPropertyName ;
2225 private readonly bool _eager ;
2326 private readonly string _associatedEntityName ;
2427 private readonly bool _unwrapProxy ;
@@ -38,8 +41,12 @@ public abstract partial class EntityType : AbstractType, IAssociationType
3841 /// </param>
3942 protected internal EntityType ( string entityName , string uniqueKeyPropertyName , bool eager , bool unwrapProxy )
4043 {
41- _associatedEntityName = entityName ;
44+ #pragma warning disable 618
4245 this . uniqueKeyPropertyName = uniqueKeyPropertyName ;
46+ #pragma warning restore 618
47+
48+ _associatedEntityName = entityName ;
49+ _uniqueKeyPropertyName = uniqueKeyPropertyName ;
4350 _eager = eager ;
4451 _unwrapProxy = unwrapProxy ;
4552 }
@@ -163,12 +170,12 @@ protected internal object GetReferenceValue(object value, ISessionImplementor se
163170 else
164171 {
165172 IEntityPersister entityPersister = session . Factory . GetEntityPersister ( GetAssociatedEntityName ( ) ) ;
166- object propertyValue = entityPersister . GetPropertyValue ( value , uniqueKeyPropertyName ) ;
173+ object propertyValue = entityPersister . GetPropertyValue ( value , _uniqueKeyPropertyName ) ;
167174
168175 // We now have the value of the property-ref we reference. However,
169176 // we need to dig a little deeper, as that property might also be
170177 // an entity type, in which case we need to resolve its identitifier
171- IType type = entityPersister . GetPropertyType ( uniqueKeyPropertyName ) ;
178+ IType type = entityPersister . GetPropertyType ( _uniqueKeyPropertyName ) ;
172179 if ( type . IsEntityType )
173180 {
174181 propertyValue = ( ( EntityType ) type ) . GetReferenceValue ( propertyValue , session ) ;
@@ -272,7 +279,7 @@ public sealed override object NullSafeGet(DbDataReader rs, string[] names, ISess
272279
273280 public bool IsUniqueKeyReference
274281 {
275- get { return uniqueKeyPropertyName != null ; }
282+ get { return _uniqueKeyPropertyName != null ; }
276283 }
277284
278285 public abstract bool IsNullable { get ; }
@@ -300,7 +307,7 @@ public IType GetIdentifierOrUniqueKeyType(IMapping factory)
300307 }
301308 else
302309 {
303- IType type = factory . GetReferencedPropertyType ( GetAssociatedEntityName ( ) , uniqueKeyPropertyName ) ;
310+ IType type = factory . GetReferencedPropertyType ( GetAssociatedEntityName ( ) , _uniqueKeyPropertyName ) ;
304311 if ( type . IsEntityType )
305312 {
306313 type = ( ( EntityType ) type ) . GetIdentifierOrUniqueKeyType ( factory ) ;
@@ -322,7 +329,7 @@ public string GetIdentifierOrUniqueKeyPropertyName(IMapping factory)
322329 }
323330 else
324331 {
325- return uniqueKeyPropertyName ;
332+ return _uniqueKeyPropertyName ;
326333 }
327334 }
328335
@@ -387,7 +394,7 @@ public override object ResolveIdentifier(object value, ISessionImplementor sessi
387394 }
388395 else
389396 {
390- return LoadByUniqueKey ( GetAssociatedEntityName ( ) , uniqueKeyPropertyName , value , session ) ;
397+ return LoadByUniqueKey ( GetAssociatedEntityName ( ) , _uniqueKeyPropertyName , value , session ) ;
391398 }
392399 }
393400
@@ -420,7 +427,7 @@ public string GetAssociatedEntityName()
420427
421428 public string LHSPropertyName => null ;
422429
423- public string RHSUniqueKeyPropertyName => uniqueKeyPropertyName ;
430+ public string RHSUniqueKeyPropertyName => _uniqueKeyPropertyName ;
424431
425432 public virtual string PropertyName => null ;
426433
@@ -448,7 +455,7 @@ public override int GetHashCode(object x, ISessionFactoryImplementor factory)
448455
449456 public abstract bool IsAlwaysDirtyChecked { get ; }
450457
451- public bool IsReferenceToPrimaryKey => string . IsNullOrEmpty ( uniqueKeyPropertyName ) ;
458+ public bool IsReferenceToPrimaryKey => string . IsNullOrEmpty ( _uniqueKeyPropertyName ) ;
452459
453460 public string GetOnCondition ( string alias , ISessionFactoryImplementor factory , IDictionary < string , IFilter > enabledFilters )
454461 {
0 commit comments