I use NHibernate for an e-commerce site, and it's hard for me to get what should be a simple mapping to work. Essentially, I have a ContactDetails object that is used to store contact information for any user - buyer / seller / advertiser / etc. I use "any" matching so that one table can store contact_details contacts for each type. The identifier is written to contact_details_id and type (buyer / seller / advertiser) in the contact_details_type field as follows.
<class name="ContactDetails" table="contact_details">
<id name="ID">
<generator class="hilo" />
</id>
<any name="Party" id-type="System.Int32" meta-type="System.String" cascade="all">
<meta-value value="buyer" class="Buyer" />
<meta-value value="seller" class="Seller" />
<column name="contact_details_type" />
<column name="contact_details_id" />
</any>
In my customer mapping, I have one-to-one contact details that look like this
<one-to-one name="ContactDetails" class="ContactDetails" cascade="all" />
, . , , ContactDetails . , contact_details_id, ID contact_details. , , , (contact_details_id). - , , ? , , .
,
JP