@@ -103,7 +103,7 @@ public void Bind(IEnumerable<IEntityPropertyMapping> properties, Table table, ID
103
103
{
104
104
var value = new SimpleValue ( table ) ;
105
105
new ValuePropertyBinder ( value , Mappings ) . BindSimpleValue ( propertyMapping , propertyName , true ) ;
106
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
106
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
107
107
BindValueProperty ( propertyMapping , property ) ;
108
108
}
109
109
else if ( ( collectionMapping = entityPropertyMapping as ICollectionPropertiesMapping ) != null )
@@ -124,14 +124,14 @@ public void Bind(IEnumerable<IEntityPropertyMapping> properties, Table table, ID
124
124
var subpath = propertyName == null ? null : StringHelper . Qualify ( propertyBasePath , propertyName ) ;
125
125
var value = CreateNewComponent ( table ) ;
126
126
BindComponent ( propertiesMapping , value , null , entityName , subpath , componetDefaultNullable , inheritedMetas ) ;
127
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
127
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
128
128
BindComponentProperty ( propertiesMapping , property , value ) ;
129
129
}
130
130
else if ( ( manyToOneMapping = entityPropertyMapping as HbmManyToOne ) != null )
131
131
{
132
132
var value = new ManyToOne ( table ) ;
133
133
BindManyToOne ( manyToOneMapping , value , propertyName , true ) ;
134
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
134
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
135
135
BindManyToOneProperty ( manyToOneMapping , property ) ;
136
136
}
137
137
else if ( ( componentMapping = entityPropertyMapping as HbmComponent ) != null )
@@ -141,14 +141,14 @@ public void Bind(IEnumerable<IEntityPropertyMapping> properties, Table table, ID
141
141
// NH: Modified from H2.1 to allow specifying the type explicitly using class attribute
142
142
System . Type reflectedClass = mappedClass == null ? null : GetPropertyType ( componentMapping . Class , mappedClass , propertyName , componentMapping . Access ) ;
143
143
BindComponent ( componentMapping , value , reflectedClass , entityName , subpath , componetDefaultNullable , inheritedMetas ) ;
144
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
144
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
145
145
BindComponentProperty ( componentMapping , property , value ) ;
146
146
}
147
147
else if ( ( oneToOneMapping = entityPropertyMapping as HbmOneToOne ) != null )
148
148
{
149
149
var value = new OneToOne ( table , persistentClass ) ;
150
150
BindOneToOne ( oneToOneMapping , value ) ;
151
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
151
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
152
152
BindOneToOneProperty ( oneToOneMapping , property ) ;
153
153
}
154
154
else if ( ( dynamicComponentMapping = entityPropertyMapping as HbmDynamicComponent ) != null )
@@ -158,14 +158,14 @@ public void Bind(IEnumerable<IEntityPropertyMapping> properties, Table table, ID
158
158
// NH: Modified from H2.1 to allow specifying the type explicitly using class attribute
159
159
System . Type reflectedClass = mappedClass == null ? null : GetPropertyType ( dynamicComponentMapping . Class , mappedClass , propertyName , dynamicComponentMapping . Access ) ;
160
160
BindComponent ( dynamicComponentMapping , value , reflectedClass , entityName , subpath , componetDefaultNullable , inheritedMetas ) ;
161
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
161
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
162
162
BindComponentProperty ( dynamicComponentMapping , property , value ) ;
163
163
}
164
164
else if ( ( anyMapping = entityPropertyMapping as HbmAny ) != null )
165
165
{
166
166
var value = new Any ( table ) ;
167
167
BindAny ( anyMapping , value , true ) ;
168
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
168
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
169
169
BindAnyProperty ( anyMapping , property ) ;
170
170
}
171
171
else if ( ( nestedCompositeElementMapping = entityPropertyMapping as HbmNestedCompositeElement ) != null )
@@ -179,19 +179,19 @@ public void Bind(IEnumerable<IEntityPropertyMapping> properties, Table table, ID
179
179
// NH: Modified from H2.1 to allow specifying the type explicitly using class attribute
180
180
System . Type reflectedClass = mappedClass == null ? null : GetPropertyType ( nestedCompositeElementMapping . Class , mappedClass , propertyName , nestedCompositeElementMapping . access ) ;
181
181
BindComponent ( nestedCompositeElementMapping , value , reflectedClass , entityName , subpath , componetDefaultNullable , inheritedMetas ) ;
182
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
182
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
183
183
}
184
184
else if ( ( keyPropertyMapping = entityPropertyMapping as HbmKeyProperty ) != null )
185
185
{
186
186
var value = new SimpleValue ( table ) ;
187
187
new ValuePropertyBinder ( value , Mappings ) . BindSimpleValue ( keyPropertyMapping , propertyName , componetDefaultNullable ) ;
188
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
188
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
189
189
}
190
190
else if ( ( keyManyToOneMapping = entityPropertyMapping as HbmKeyManyToOne ) != null )
191
191
{
192
192
var value = new ManyToOne ( table ) ;
193
193
BindKeyManyToOne ( keyManyToOneMapping , value , propertyName , componetDefaultNullable ) ;
194
- property = CreateProperty ( entityPropertyMapping , className , value , inheritedMetas ) ;
194
+ property = CreateProperty ( entityPropertyMapping , mappedClass , value , inheritedMetas ) ;
195
195
}
196
196
197
197
if ( property != null )
@@ -402,31 +402,52 @@ private void BindCollectionProperty(ICollectionPropertiesMapping collectionMappi
402
402
property . Cascade = collectionMapping . Cascade ?? mappings . DefaultCascade ;
403
403
}
404
404
405
- private Property CreateProperty ( IEntityPropertyMapping propertyMapping , string propertyOwnerClassName , IValue value , IDictionary < string , MetaAttribute > inheritedMetas )
405
+ private Property CreateProperty ( IEntityPropertyMapping propertyMapping , System . Type propertyOwnerType , SimpleValue value , IDictionary < string , MetaAttribute > inheritedMetas )
406
406
{
407
407
if ( string . IsNullOrEmpty ( propertyMapping . Name ) )
408
408
{
409
- throw new MappingException ( "A property mapping must define the name attribute [" + propertyOwnerClassName + "]" ) ;
409
+ throw new MappingException ( "A property mapping must define the name attribute [" + propertyOwnerType + "]" ) ;
410
410
}
411
411
412
412
var propertyAccessorName = GetPropertyAccessorName ( propertyMapping . Access ) ;
413
413
414
- if ( ! string . IsNullOrEmpty ( propertyOwnerClassName ) && value . IsSimpleValue )
415
- value . SetTypeUsingReflection ( propertyOwnerClassName , propertyMapping . Name , propertyAccessorName ) ;
414
+ if ( propertyOwnerType != null && value . IsSimpleValue )
415
+ value . SetTypeUsingReflection ( propertyOwnerType , propertyMapping . Name , propertyAccessorName ) ;
416
416
417
417
var property = new Property
418
- {
419
- Name = propertyMapping . Name ,
420
- PropertyAccessorName = propertyAccessorName ,
421
- Value = value ,
422
- IsLazy = propertyMapping . IsLazyProperty ,
423
- LazyGroup = propertyMapping . GetLazyGroup ( ) ,
424
- IsOptimisticLocked = propertyMapping . OptimisticLock ,
425
- MetaAttributes = GetMetas ( propertyMapping , inheritedMetas )
426
- } ;
418
+ {
419
+ Name = propertyMapping . Name ,
420
+ PropertyAccessorName = propertyAccessorName ,
421
+ Value = value ,
422
+ IsLazy = propertyMapping . IsLazyProperty ,
423
+ LazyGroup = propertyMapping . GetLazyGroup ( ) ,
424
+ IsOptimisticLocked = propertyMapping . OptimisticLock ,
425
+ MetaAttributes = GetMetas ( propertyMapping , inheritedMetas )
426
+ } ;
427
427
428
428
return property ;
429
429
}
430
+
431
+ private Property CreateProperty ( IEntityPropertyMapping propertyMapping , string propertyOwnerClassName , Mapping . Collection value , IDictionary < string , MetaAttribute > inheritedMetas )
432
+ {
433
+ if ( string . IsNullOrEmpty ( propertyMapping . Name ) )
434
+ {
435
+ throw new MappingException ( "A property mapping must define the name attribute [" + propertyOwnerClassName + "]" ) ;
436
+ }
437
+
438
+ var propertyAccessorName = GetPropertyAccessorName ( propertyMapping . Access ) ;
439
+
440
+ return new Property
441
+ {
442
+ Name = propertyMapping . Name ,
443
+ PropertyAccessorName = propertyAccessorName ,
444
+ Value = value ,
445
+ IsLazy = propertyMapping . IsLazyProperty ,
446
+ LazyGroup = propertyMapping . GetLazyGroup ( ) ,
447
+ IsOptimisticLocked = propertyMapping . OptimisticLock ,
448
+ MetaAttributes = GetMetas ( propertyMapping , inheritedMetas )
449
+ } ;
450
+ }
430
451
431
452
private string GetPropertyAccessorName ( string propertyMappedAccessor )
432
453
{
0 commit comments