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

Posted on 2005-04-08
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:

PK,FK1 report_def_id
PK,FK1 column_id
PK function

PK,FK2 report_def_id
PK,FK3 column_id

Thank you very much for your help!
Question by:stephan_zehnder
    LVL 17

    Expert Comment

    by:Dejan Pažin

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

    Accepted Solution


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    nested interface 5 30
    java constructor error 8 66
    matchUp  challenge 9 51
    bunnyEars challenge 6 47
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now