• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with one-to-one mapping using discriminator

 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to map distinct variations of a table entry by using a discriminator-value.

I have a table called Agreement. The entries in this table could be of many AgreementTypes. Some, but not all agreements have an AgreementDetail.
The table AgreementDetail is mapped in its own mapping file.

I want only those I discriminate to get an AgreementDetail. This I will define in the subclass.

There is a one-to-one relationship between Agreement and AgreementDetail, but trying to define a <one-to-one></one-to-one> does not work. The primary keys of AgreementDetail has the same primary keys as Agreement, plus one more. Its those two primary keys of Agreement I must use to find an AgreementDetail.

By trying the following I get the error message "broken coulmn mapping for agreementDetail.id of: AgreementDetail"
<one-to-one name="agreementDetail" class="AgreementDetail"></one-to-one>

Here are a piece of my mapping. This mapping work as it is, but has no AgreementDetail mapping for the subclass.


[ April 21, 2008: Message edited by: Sverre Moe ]
[ April 21, 2008: Message edited by: Sverre Moe ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
discriminators are used for Inheritance mapping, not relational mapping.

To map one-to-one follow the documentation here

http://www.hibernate.org/hib_docs/v3/reference/en/html/associations.html#assoc-bidirectional-121

I am thinking your mapping might just be a straight simple One-to-one mapping like in the documentation.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic