Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

OneToOne composite key

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get this failure by mapping a OneToOne-Relationship:



The ProductID of table Product is a composite key which has the SAME Columns than the composite key ItemID in table Item:







This HQL works and returns the item-instance of a product:



This HQL does not work and returns the exception:







Instead of JoinColumn, I have tried it with PrimaryKeyJoinColumns (the same exception occurs):



(Another point is, when I annotate the @OneToOne above the getter instead above the field, then Hibernate totally ignores my OneToOne-Mapping and recognices the Item-Instance (or Product-Instance) as a column instead of a relationship, hence it produces false sql-selects)


I have also tried to use the PrimaryKeyJoinColumns-Relation in Class Product:



and delete the relation in Class Item
(to make the oneToOne at least unidirectional):



Doing that HQL:



returns the same failure:



Do I have to use Hibernates ForeignGenerator within my Item-Class (I have a composite key!) ?:




Please, can you say me: What is wrong with my mapping?


It is really hard to believe that such a OneToOne-Mapping with a composite key is so hard to implement by using ORM (Hibernate).
Such relationships are very common.
 
no wonder he is so sad, he hasn't seen this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!