Hi Tom,

I only just got around to looking at your example. Your suggestion makes
sense. Have you attempted to make the necessary modifications to FNH to use
this new approach?

Paul.

On Tue, Feb 16, 2010 at 9:56 PM, Tom Janssens <d4sk...@gmail.com> wrote:

> Hi Paul,
>
> Sorry for the late answer.Thank you for taking the time to reply.
>
> AFAIK the current system only recalls the latest names for a
> component; since you only have the current propertyinfo available,
> So this would result in
>
> - HomeStreet
> - HomeNr
> - City_Id
> - WorkStreet
> - WorkNr
> - City_Id
>
> This is the resulting hbm file :
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> access="property" auto-import="true" default-cascade="none" default-
> lazy="true">
>  <class xmlns="urn:nhibernate-mapping-2.2"
> name="FluentNhibExample.Model.Contact, FluentNhibExample,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> table="`Contact`">
>    <id name="Id" type="System.Int32, mscorlib, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089">
>      <column name="Id" />
>      <generator class="identity" />
>    </id>
>    <component name="Coordinate" insert="true" update="true"
> optimistic-lock="true">
>      <component name="Home" insert="true" update="true" optimistic-
> lock="true">
>        <property name="Street" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>          <column name="HomeStreet" />
>        </property>
>        <property name="Nr" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>          <column name="HomeNr" />
>        </property>
>        <many-to-one cascade="save-update"
> class="FluentNhibExample.Model.City, FluentNhibExample,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="City">
>          <column name="City_id" />
>        </many-to-one>
>      </component>
>      <component name="Work" insert="true" update="true" optimistic-
> lock="true">
>        <property name="Street" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>          <column name="WorkStreet" />
>        </property>
>        <property name="Nr" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>          <column name="WorkNr" />
>        </property>
>        <many-to-one cascade="save-update"
> class="FluentNhibExample.Model.City, FluentNhibExample,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="City">
>          <column name="City_id" />
>        </many-to-one>
>      </component>
>    </component>
>    <property name="Name" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>      <column name="Name" />
>    </property>
>  </class>
> </hibernate-mapping>
>
> I know this might be a stupid example, but when we add for example the
> following class as a component:
>    public class EmailAddress
>    {
>        protected Regex MyRegex = new Regex(@"[a-za-z0-9._%...@[a-za-
> z0-9.-]+\.[A-Za-z]{2,4}");
>        private string val;
>
>        public string Value
>        {
>            get
>            {
>                return val;
>            }
>            set
>            {
>                if (val != null)
>                {
>                    val = val.ToLowerInvariant();
>                    if (!MyRegex.Match(value).Success)
>                        throw (new
> ArgumentOutOfRangeException("Invalid email address"));
>                }
>                val = value;
>            }
>        }
>    }
>
> and add it to the Address class:
>     public class Address
>    {
>        public virtual string Street { get; set; }
>        public virtual string Nr { get; set; }
>        public virtual City City { get; set; }
>         public virtual EmailAddress Email { get; set; }
>    }
>
> this results in the following mapping :
>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> access="property" auto-import="true" default-cascade="none" default-
> lazy="true">
>  <class xmlns="urn:nhibernate-mapping-2.2"
> name="FluentNhibExample.Model.Contact, FluentNhibExample,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> table="`Contact`">
>    <id name="Id" type="System.Int32, mscorlib, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089">
>      <column name="Id" />
>      <generator class="identity" />
>    </id>
>    <component name="Coordinate" insert="true" update="true"
> optimistic-lock="true">
>      <component name="Home" insert="true" update="true" optimistic-
> lock="true">
>        <component name="Email" insert="true" update="true" optimistic-
> lock="true">
>          <property name="Value" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>            <column name="EmailValue" />
>          </property>
>        </component>
>        <property name="Street" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>          <column name="HomeStreet" />
>        </property>
>        <property name="Nr" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>          <column name="HomeNr" />
>        </property>
>        <many-to-one cascade="save-update"
> class="FluentNhibExample.Model.City, FluentNhibExample,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="City">
>          <column name="City_id" />
>        </many-to-one>
>      </component>
>      <component name="Work" insert="true" update="true" optimistic-
> lock="true">
>        <component name="Email" insert="true" update="true" optimistic-
> lock="true">
>          <property name="Value" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>            <column name="EmailValue" />
>          </property>
>        </component>
>        <property name="Street" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>          <column name="WorkStreet" />
>        </property>
>        <property name="Nr" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>          <column name="WorkNr" />
>        </property>
>        <many-to-one cascade="save-update"
> class="FluentNhibExample.Model.City, FluentNhibExample,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="City">
>          <column name="City_id" />
>        </many-to-one>
>      </component>
>    </component>
>    <property name="Name" type="System.String, mscorlib,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>      <column name="Name" />
>    </property>
>  </class>
> </hibernate-mapping>
>
> As you can see, we have 2 columns named "EmailValue" here. This is
> what I mean with top-down naming :
> the name should be componentname.componentname.propertyname (i.e.
> HomeAddressEmailValue) IMHO.
>
> Do you think this would be a good idea ?
>
> The project is available here: http://gist.github.com/305454 (it uses
> my own fluentnhibernate wrapper, but should be quite obvious)
>
> Kind regards,
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-nhibern...@googlegroups.com.
> To unsubscribe from this group, send email to
> fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to