@@ -17,8 +17,11 @@ namespace NHibernate.Type
17
17
[ Serializable ]
18
18
public abstract partial class EntityType : AbstractType , IAssociationType
19
19
{
20
+ // Since v5.1
21
+ [ Obsolete ( "This field has no more usages in NHibernate and will be removed. Use RHSUniqueKeyPropertyName instead." ) ]
20
22
protected readonly string uniqueKeyPropertyName ;
21
23
24
+ private readonly string _uniqueKeyPropertyName ;
22
25
private readonly bool _eager ;
23
26
private readonly string _associatedEntityName ;
24
27
private readonly bool _unwrapProxy ;
@@ -38,8 +41,12 @@ public abstract partial class EntityType : AbstractType, IAssociationType
38
41
/// </param>
39
42
protected internal EntityType ( string entityName , string uniqueKeyPropertyName , bool eager , bool unwrapProxy )
40
43
{
41
- _associatedEntityName = entityName ;
44
+ #pragma warning disable 618
42
45
this . uniqueKeyPropertyName = uniqueKeyPropertyName ;
46
+ #pragma warning restore 618
47
+
48
+ _associatedEntityName = entityName ;
49
+ _uniqueKeyPropertyName = uniqueKeyPropertyName ;
43
50
_eager = eager ;
44
51
_unwrapProxy = unwrapProxy ;
45
52
}
@@ -163,12 +170,12 @@ protected internal object GetReferenceValue(object value, ISessionImplementor se
163
170
else
164
171
{
165
172
IEntityPersister entityPersister = session . Factory . GetEntityPersister ( GetAssociatedEntityName ( ) ) ;
166
- object propertyValue = entityPersister . GetPropertyValue ( value , uniqueKeyPropertyName ) ;
173
+ object propertyValue = entityPersister . GetPropertyValue ( value , _uniqueKeyPropertyName ) ;
167
174
168
175
// We now have the value of the property-ref we reference. However,
169
176
// we need to dig a little deeper, as that property might also be
170
177
// an entity type, in which case we need to resolve its identitifier
171
- IType type = entityPersister . GetPropertyType ( uniqueKeyPropertyName ) ;
178
+ IType type = entityPersister . GetPropertyType ( _uniqueKeyPropertyName ) ;
172
179
if ( type . IsEntityType )
173
180
{
174
181
propertyValue = ( ( EntityType ) type ) . GetReferenceValue ( propertyValue , session ) ;
@@ -272,7 +279,7 @@ public sealed override object NullSafeGet(DbDataReader rs, string[] names, ISess
272
279
273
280
public bool IsUniqueKeyReference
274
281
{
275
- get { return uniqueKeyPropertyName != null ; }
282
+ get { return _uniqueKeyPropertyName != null ; }
276
283
}
277
284
278
285
public abstract bool IsNullable { get ; }
@@ -300,7 +307,7 @@ public IType GetIdentifierOrUniqueKeyType(IMapping factory)
300
307
}
301
308
else
302
309
{
303
- IType type = factory . GetReferencedPropertyType ( GetAssociatedEntityName ( ) , uniqueKeyPropertyName ) ;
310
+ IType type = factory . GetReferencedPropertyType ( GetAssociatedEntityName ( ) , _uniqueKeyPropertyName ) ;
304
311
if ( type . IsEntityType )
305
312
{
306
313
type = ( ( EntityType ) type ) . GetIdentifierOrUniqueKeyType ( factory ) ;
@@ -322,7 +329,7 @@ public string GetIdentifierOrUniqueKeyPropertyName(IMapping factory)
322
329
}
323
330
else
324
331
{
325
- return uniqueKeyPropertyName ;
332
+ return _uniqueKeyPropertyName ;
326
333
}
327
334
}
328
335
@@ -387,7 +394,7 @@ public override object ResolveIdentifier(object value, ISessionImplementor sessi
387
394
}
388
395
else
389
396
{
390
- return LoadByUniqueKey ( GetAssociatedEntityName ( ) , uniqueKeyPropertyName , value , session ) ;
397
+ return LoadByUniqueKey ( GetAssociatedEntityName ( ) , _uniqueKeyPropertyName , value , session ) ;
391
398
}
392
399
}
393
400
@@ -420,7 +427,7 @@ public string GetAssociatedEntityName()
420
427
421
428
public string LHSPropertyName => null ;
422
429
423
- public string RHSUniqueKeyPropertyName => uniqueKeyPropertyName ;
430
+ public string RHSUniqueKeyPropertyName => _uniqueKeyPropertyName ;
424
431
425
432
public virtual string PropertyName => null ;
426
433
@@ -448,7 +455,7 @@ public override int GetHashCode(object x, ISessionFactoryImplementor factory)
448
455
449
456
public abstract bool IsAlwaysDirtyChecked { get ; }
450
457
451
- public bool IsReferenceToPrimaryKey => string . IsNullOrEmpty ( uniqueKeyPropertyName ) ;
458
+ public bool IsReferenceToPrimaryKey => string . IsNullOrEmpty ( _uniqueKeyPropertyName ) ;
452
459
453
460
public string GetOnCondition ( string alias , ISessionFactoryImplementor factory , IDictionary < string , IFilter > enabledFilters )
454
461
{
0 commit comments