Hi,
I just wanted to check that I didn't miss something in the manual - is it possible to map a collection on a table where the join constraint is not the primary key?
My attempts just got me a join based on the primary key which was bad, but at least it wasn't null, but that was only when I loaded the RoomItem (see below) as part of a collection. If I used get(id, type) to get the room item, then the ReadOnlyProperties collection was undefined.
I can get around this by using criteria to return a list of ReadOnlyProperties, but it'd be nice to have it in my AssetRoomItem object.
Thanks,
Brett.
Hibernate version: NHibernate 1.2.0.Alpha1
Name and version of the database you are using:SQL Server 2000
Mapping File:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo">
<class name="Domain.RoomItem, Core" table="nrp_RoomItem">
<id name="ID" type="Int32" column="RoomItemID" unsaved-value="0">
<generator class="identity" />
</id>
<many-to-one name="OnLayer" column="LayerID" class="Domain.Layer, Core" />
<many-to-one name="OfCategory" column="CategoryID" class="Domain.Category, Core" />
<map name="Properties" inverse="true" cascade="all" lazy="true">
<key column="RoomItemID" />
<index column="PropertyID" type="System.Int32"/>
<one-to-many class="Domain.RoomItemProperty, Core" />
</map>
<joined-subclass name="Domain.AssetRoomItem, Core" table="nrp_AssetRoomItem">
<key column="RoomItemID"/>
<property name="AssetID" type="Int32"/>
<bag name="ReadOnlyProperties" inverse="true" lazy="true">
<key column="AssetID" foreign-key="AssetID" />
<one-to-many class="Domain.ReadOnlyAssetProperty, Core" />
</bag>
</joined-subclass>
</class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-lazy="false">
<class
name="Domain.ReadOnlyAssetProperty, Core"
table="dbo.nrp_AssetPropertyView" mutable="false">
<composite-id name="CompositeID" class="Domain.ReadOnlyAssetPropertyID, Core" >
<key-property name="AssetID" column="AssetID" type="Int32" />
<key-property name="ID" column="PropertyID" type="Int32"/>
</composite-id>
<property name="Value" column="Value"/>
</class>
</hibernate-mapping>
|