FluentNHibernate Component.ColumnPrefix not applicable

I recently upgraded FluentNHibernate from v1.1.0.685 to v1.2.0.712 (latest) for NHibernate 2.1 .

My problem is with classes using mapping Component().ColumnPrefix().

For instance,

 public class Address{ 
    public string Street {get; set;} 
    public string Zip {get; set;} 
 } 

 public class AddressMap : ComponentMap<Address>{
     Map( x => x.Street );
     Map( x => x.Zip );
 }

 public class PersonMap : ClassMap<Person> 
 { 
    public PersonMap(){ 

       Id( x => x.Id ); 

       Map( x=> x.Name ); 

       Component( x => x.Address ) 
          .ColumnPrefix("ADDRESS_"); 
    } 
 } 

Face table

  Id       Name        ADDRESS_Street     ADDRESS_Zip
 ----------------------------------------------------
  1        Brian       123 Example St.    12345

Behavior in FNH v1.1.0.685

The prefix "ADDRESS _" is correctly applied to the properties of the Address component.

Behavior in FNH v1.2.0.712 (latest)

"ADDRESS _" Address. NHiberante "" ", .


, - . , .

,
Brian

+3
3

; , - FNH v1.1 FNH v1.2.

, :

  • AddressMap : ComponentMap<Address> ( ).

  • My PersonMap : ClassMap<Person> , :

    Component( x => x.Address ).ColumnPrefix("ADDRESS_"); 
    

    1.

  • FNH MyPropertyConvention :

    public class MyPropertyConvention : IPropertyConvention
    {
        public void Apply( IPropertyInstance instance )
        {
            instance.Column( instance.Name ); //this call is destructive
                                              //to ColumnPrefix() in FNH v1.2
        }
    }
    

:

  • FNH v1.1, 3 instance.Column().

  • FNH v1.2, 3 ColumnPrefix() ( ).

, FNH 1.2, IPropertyConventionAcceptance, instance.Column(instance.Name) [ ].

,
Brian

+1

@,

- . , :

Public Class ComponentPropertyConvention
    Implements IPropertyConvention, IPropertyConventionAcceptance

    Public Sub Accept(ByVal criteria As IAcceptanceCriteria(Of IPropertyInspector)) Implements IConventionAcceptance(Of IPropertyInspector).Accept
       criteria.Expect(Function(inspector) inspector.EntityType.Namespace.EndsWith("Components"))
    End Sub

    Public Sub Apply(ByVal instance As IPropertyInstance) Implements IConvention(Of IPropertyInspector, IPropertyInstance).Apply
        instance.Column(String.Format("{0}_{1}", New String() {instance.EntityType.Name.ToLower(), instance.Property.Name.Dbize()}))
    End Sub

End Class

, , , ...

+1

You need to create a class ComponentMap<Address>to apply ColumnPrefix.

See here: http://wiki.fluentnhibernate.org/Fluent_mapping#ComponentMap.3CT.3E

0
source

All Articles