JB
unread,Sep 7, 2010, 12:06:11 PM9/7/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to S#arp Architecture
I'm having a problem with overriding the Id column name. I'm using the
latest S#arp Architecture 1.6 VS 2008 Template (No Source) download
that was uploaded on 2010-08-17. For some reason no matter what I do I
can't seem to change the name of the Id column. I have a mapping
override that looks like this:
public class CarrierMap : IAutoMappingOverride<Carrier>
{
public void Override(AutoMapping<Carrier> mapping)
{
mapping.Id(x => x.Id, "CARRIER_CODE")
.GeneratedBy.Assigned();
mapping.OptimisticLock.Version();
mapping.Version(x => x.Version)
.Column("VERSION")
.UnsavedValue("negative");
mapping.Map(x => x.Name, "CARRIER_NAME");
mapping.Map(x => x.Info, "CARRIER_INFO");
mapping.Map(x => x.IsActive,
"ACTIVE").CustomType("YesNo");
mapping.Map(x => x.CreatedBy, "OPERATOR_ID").Not.Update();
mapping.Map(x => x.CreatedOn,
"CREATE_DATE").Not.Update().CustomType("Timestamp");
mapping.Map(x => x.LastModifiedBy, "LAST_MODIFIED_USER");
mapping.Map(x => x.LastModifiedOn,
"LAST_MODIFIED_DATE").CustomType("Timestamp");
}
}
I created a quick unit test to output the mappings to check them that
looks like this:
[Test]
public void CreateHbmXmlMappings()
{
string path = @"c:\HBM";
AutoPersistenceModel model = new
AutoPersistenceModelGenerator().Generate();
model.WriteMappingsTo(path);
}
The generated hbm.xml file looks like this:
<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" mutable="true" optimistic-
lock="version" name="iPFSv2.Core.Carrier, iPFSv2.Core,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
table="PFS_CARRIERS_011">
<id name="Id" type="System.String, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Id" />
<generator class="assigned" />
</id>
<version name="Version" type="System.Int32, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
unsaved-value="negative">
<column name="VERSION" />
</version>
<property name="Name" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="CARRIER_NAME" />
</property>
<property name="Info" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="CARRIER_INFO" />
</property>
<property name="IsActive" type="YesNo">
<column name="ACTIVE" />
</property>
<property name="CreatedBy" update="false" type="System.String,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
<column name="OPERATOR_ID" />
</property>
<property name="CreatedOn" update="false" type="Timestamp">
<column name="CREATE_DATE" />
</property>
<property name="LastModifiedBy" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="LAST_MODIFIED_USER" />
</property>
<property name="LastModifiedOn" type="Timestamp">
<column name="LAST_MODIFIED_DATE" />
</property>
</class>
</hibernate-mapping>
You'll notice that everything except the ID column name is overridden
properly. It should have a column name = CARRIER_CODE, but for some
reason it is still Id.
I've gotten the latest version of Fluent-NHibernate and created some
similar tests with their latest source and this isn't a problem.
Overriding the Id column name works fine. I'm guessing this has
something to do with whatever version you included with the latest
release of sharp.