jQuery in Action, 2nd edition*
The moose likes Object Relational Mapping and the fly likes Hibernate composite id mapping through HQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate composite id mapping through HQL" Watch "Hibernate composite id mapping through HQL" New topic
Author

Hibernate composite id mapping through HQL

Adam Kovari
Greenhorn

Joined: Aug 08, 2008
Posts: 7
Hi,
i have table with composite PK:

and i need other table to join it with many-to-one relationship:

the name="kategoria" stands for name of column in Zadanie table which contains id value of Ciselnik table.
But the problem is that my class Zadanie contans only ID column of Ciselnik class and i need to specify typ and jazyk in HQL Query, but i have no idea what i need to specify in my Zadanie class and how to write HQL Query.

Please keep in mind that i'm very new to hibernate and and i'm rewriting existing model to use hibernate, so i wouldn't like to change DB schema.

Thank you
Adam Kovari
Ramesh Srinivasan
Ranch Hand

Joined: Aug 17, 2008
Posts: 35
Originally posted by Adam Kovari:
[QB]Hi,
i have table with composite PK:


Hi Kovari,

Please use a separate bean for composite id's. Make sure that this class should be SERIALIZED. When you writing your HQL's you need to pass the PK from the created one.

~Ramesh


SCJP 5.0 93%<br /> <br />"We are what we repeatedly do , then excellence is not an action it is an Habit" Aristotle
 
 
subject: Hibernate composite id mapping through HQL
 
Similar Threads
Join Table many-to-one issue
Please suggest on this Mapping
Two PKs
Hibernate: Different Join in Save() and Get()
Validating Hibernate mapping file with -set- and -join- elements