?
Solved

Hibernate: How to map a foreign key with multiple columns?

Posted on 2005-04-08
2
Medium Priority
?
3,554 Views
Last Modified: 2008-01-09
How can I map a foregin key constraint with multiple columns in hibernate?

I have a table report_field with a primary key of two columns (report_def_id and column_id) which itself are foreign keys. Than I have a table function with a primary key of two columns (function, report_def_id and column_id). So the primary_key of one table is contained in the primary key in the other table and is a foreign key.

This is how the table structure looks like:

function
---------
PK,FK1 report_def_id
PK,FK1 column_id
PK function
.
.
.

report_field
-------------
PK,FK2 report_def_id
PK,FK3 column_id
.
.
.

Thank you very much for your help!
0
Comment
Question by:stephan_zehnder
2 Comments
 
LVL 17

Expert Comment

by:Dejan Pažin
ID: 13738570

You can use a component as a composite identifier, take a look here:

http://www.hibernate.org/hib_docs/reference/en/html/components.html#components-compositeid
0
 
LVL 15

Accepted Solution

by:
aozarov earned 1500 total points
ID: 13742444
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question