Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6002863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:02:21+00:00 2026-05-23T01:02:21+00:00

I have two related entities being mapped by JPA annotations backed by hibernate. The

  • 0

I have two related entities being mapped by JPA annotations backed by hibernate. The entities both have sequence-backed identity columns in oracle. Our also have monthly partitions, represented by a column called ENTRY_DATE.

T_MASTER     T_JOINED
---------    ----------- 
MASTER_ID    JOINED_ID 
ENTRY_DATE   ENTRY_DATE
             MASTER_ID(FK)
...          ....

To gain the benefit of the partition key, I’d like Hibernate to join on both the identity IDs and the partition key, but when I use the following annotation in the Joined class:

@ManyToOne
@JoinColumns(value={
   @JoinColumn(name="MASTER_ID"),
   @JoinColumn(name="ENTRY_DATE")})
private Master master;

I get errors about having too many join columns. I am forced to use

 @JoinColumn(name="MASTER_ID")
 private Master master;

I’m a bit of a JPA/Hibernate noob. Is it possible to use a partition key in addition to the primary key when joining to related entities?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:02:22+00:00Added an answer on May 23, 2026 at 1:02 am

    You probably need to declare both columns as parts of composite primary key in Master. Hibernate would not care that much about what is real PK in the database. Mapping wil be slightly more complex with @Embeddable but it should solve the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two related entities (I've added all possible data annotations, but it seems
I'm using core data in my app. I have two entities that are related:
I have two related entities. Fruits.Apple Cars.Bmw Those entities belongs to the same user
I have two entities, EntityA and EntityB. EntityB can optionally be related to EntityA,
In my core data object model I have two entities that are related with
I have two related entities, say @Entity public class Book { @ManyToOne Shelf shelf;
I have two related one to many entities Race and Cars (on race contains
I have a simple situation where I have two entities related with Many-To-Many relationship.
Say I have two entities in Doctrine2 that are related to each other, Models\User
I have two entities A and B that are related in a MxN relation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.