It's not very clear what you're trying to map. In particular, you
were combining a primary key column and many to one mapping. You
need an explicit property for each part of the composite key, and then
separately map the many to one. So add a documentId property that is
an int, and then map something like the following:
By the way, I cleaned up the way you're referencing namespaces, it's a
lot simpler this way:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="db.model.transaction" assembly="db.model.transaction">
<class name="ExportDocument" table="EXPORT_DOCUMENT">
<composite-id name="exportDocumentKey" class="ExportDocumentKey">
<key-property name="documentId" column="DOCUMENT_ID" />
<key-property name="documentOccurrenceID"
column="DOCUMENT_OCCURENCE_ID" type="Int32" />
</composite-id>
<property name="recordCreateUserID" column="RECORD_CREATE_USER_ID"/
>
<property name="recordCreateTs" column="RECORD_CREATE_GMTS"/>
<many-to-one name="document" lazy="false" column="DOCUMENT_ID"
class="Document"/>
<!-- mapping to exportdocSend-->
<set name="exportDocSends" cascade="all" lazy="false"
table="EXPORT_DOC_SEND" inverse="false">
<key>
<column name="DOCUMENT_ID" not-null="true" />
<column name="DOCUMENT_OCCURENCE_ID" not-null="true"/>
</key>
</set>
</class>
<class name="ExportDocSend" table="EXPORT_DOC_SEND">
<composite-id name="exportDocSendKey" class="ExportDocSendKey">
<key-property name="documentId" column="DOCUMENT_ID"/>
<key-property name="documentOccurrenceID"
column="DOCUMENT_OCCURENCE_ID" type="Int32"/>
<key-property name="sendToDestDesc" column="SEND_DSTN_SYSTEM_DC"
type="String"/>
</composite-id>
<many-to-one name="document" column="DOCUMENT_ID" class="Document"/
>
<property name="recordCreatedUserID"
column="RECORD_CREATE_USER_ID" />
<property name="recordCreatedGmTs" column="RECORD_CREATE_GMTS" />
</class>
</hibernate-mapping>
On Feb 4, 4:00 pm, Ying Guo <[email protected]> wrote:
> Here are my mapping files
> Parent:
>
> <class name="db.model.transaction.ExportDocument" table="EXPORT_DOCUMENT">
>
> <composite-id name="exportDocumentKey" class="
> db.model.transaction.ExportDocumentKey">
>
> <key-many-to-one name="document" lazy="false" column="DOCUMENT_ID" class="
> db.model.transaction.Document"/>
>
> <key-property name="documentOccurrenceID" column="DOCUMENT_OCCURENCE_ID"
> type="Int32" />
>
> </composite-id>
>
> <property name="recordCreateUserID" column="RECORD_CREATE_USER_ID"/>
>
> <property name="recordCreateTs" column="RECORD_CREATE_GMTS"/>
>
> <!-- mapping to exportdocSend-->
>
> <set name="exportDocSends" cascade="all" lazy="false"
> table="EXPORT_DOC_SEND" inverse="false">
>
> <key>
>
> <column name="DOCUMENT_ID" not-null="true" />
>
> <column name="DOCUMENT_OCCURENCE_ID" not-null="true"/>
>
> </key>
>
> <one-to-many
> class="db.model.transaction.ExportDocSend,db.model.transaction"/>
>
> </set>
>
> Child
>
> <class name="db.model.transaction.ExportDocSend" table="EXPORT_DOC_SEND">
>
> <composite-id name="exportDocSendKey" class="
> db.model.transaction.ExportDocSendKey">
>
> <key-many-to-one name="document" column="DOCUMENT_ID" class="db.
> model.transaction.Document"/>
>
> <key-property name="documentOccurrenceID" column="DOCUMENT_OCCURENCE_ID"
> type="Int32"/>
>
> <key-property name="sendToDestDesc" column="SEND_DSTN_SYSTEM_DC" type="
> String"/>
>
> </composite-id>
>
> <property name="recordCreatedUserID" column="RECORD_CREATE_USER_ID" />
>
> <property name="recordCreatedGmTs" column="RECORD_CREATE_GMTS" />
>
> </class>
>
>
>
>
>
>
>
> On Fri, Feb 4, 2011 at 2:40 PM, Ying Guo <[email protected]> wrote:
> > thanks for the reply, however I do try this. And it does not seem to work
> > for me.
> > Won't through any exception however the collection is empty.
>
> > For single key column seems working fine.
>
> > so for this
> > <column name="key1" />
> > <column name="key2" />
> > should these be database column name?
>
> > On Fri, Feb 4, 2011 at 1:53 PM, Tim Hoolihan - @thoolihan <
> > [email protected]> wrote:
>
> >> On Feb 3, 11:42 pm, YingGuo <[email protected]> wrote:
> >> > Parent class has composite key
>
> >> > (key1,key2,fieldx,fieldy...)
>
> >> > child class has composite key
> >> > (key1,key2,key3,fielda,....)
>
> >> You didn't post a lot of detail, but here's a stab in the dark...
>
> >> <class name="Parent" ... >
> >> <composite-id>
> >> <key property="key1" ... />
> >> <key property="key2" ... />
> >> </composite-id>
> >> <set name="Child" class="Child">
> >> <key>
> >> <!-- following columns are on the child class -->
> >> <column name="key1" />
> >> <column name="key2" />
> >> </key>
> >> </set>
> >> </class>
>
> >> <class name="Child" ... >
> >> <composite-id>
> >> <key property="key1" ... />
> >> <key property="key2" ... />
> >> <key property="key3" ... />
> >> </composite-id>
> >> <many-to-one name="Parent" class="Parent">
> >> <key property="key1" ... />
> >> <key property="key2" ... />
> >> </many-to-one>
> >> </class>
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "nhusers" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected]<nhusers%[email protected]
> >> >
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/nhusers?hl=en.
--
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en.