Please disregard. Was missing the m. before "WithTable".
On Jul 15, 4:21 pm, cbright <[email protected]> wrote:
> Hello,
>
> I am trying to map an inheritance hierarchy using fluent mappings and
> the table per subclass strategy. I am specifying the table name in
> both the base class and subclass with the following mapping.
>
> public class UnitMapping : BaseMapping<Unit>
> {
> public UnitMapping()
> {
> WithTable("Units");
> Id(x => x.Id).ColumnName("unit_id");
> References(x => x.Division).WithForeignKey("division_id");
> References(x => x.Area).WithForeignKey("area_id");
> Map(x => x.Designation).ColumnName("designation");
> .....
> Map(x => x.Voltage).ColumnName("voltage");
> JoinedSubClass<Crane>("unit_id",
> m =>
> {
> WithTable("Cranes");
> m.Map(y => y.Type).ColumnName("type");
> m.Component<Hoist>(x => x.Hoist, c =>
> {
> c.Map(x => x.Type).ColumnName("hoist_type");
> c.Map(x => x.Make).ColumnName("hoist_make");
> ...
> c.Map(x => x.Voltage).ColumnName
> ("hoist_voltage");
> c.Map(x => x.Capacity).ColumnName
> ("hoist_capacity");
> });
> });
>
> }
> }
>
> This mapping produces the following hbm file
>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> access="">
> <class name="PMR.Core.Model.Unit, PMR.Core, Version=1.0.0.0,
> Culture=neutral, PublicKeyToken=null" table="Cranes"
> xmlns="urn:nhibernate-mapping-2.2">
> <id name="Id" type="Guid" column="unit_id">
> <generator class="guid.comb" />
> </id>
> <property name="Created" type="DateTime">
> <column name="created" />
> </property>
> ...
> <property name="Voltage" type="String">
> <column name="voltage" />
> </property>
> <many-to-one foreign-key="division_id" name="Division"
> column="Division_id" />
> <many-to-one foreign-key="area_id" name="Area" column="Area_id" />
> <joined-subclass name="PMR.Core.Model.Crane, PMR.Core,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
> <key column="unit_id" />
> <component name="Hoist" insert="true" update="true">
> <property name="Type" type="String">
> <column name="hoist_type" />
> </property>
> .....
> <property name="Capacity" type="String">
> <column name="hoist_capacity" />
> </property>
> </component>
> <property name="Type" type="String">
> <column name="type" />
> </property>
> </joined-subclass>
> </class>
> </hibernate-mapping>
>
> Notice how the base class has its table attribute set to "Cranes" when
> the table name is "Units" and the joined-subclass doesn't specify any
> table name attribute. In addition trying to insert a new crane
> produces a sql statement with a left outer join on "Crane". I am not
> sure if this is related.
>
> It is entirely possible I am overlooking something simple but any help
> would be appreciated.
> Thanks,
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---