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 6234777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:32:54+00:00 2026-05-24T10:32:54+00:00

I got this table structure where we are not allowed to change and i

  • 0

I got this table structure where we are not allowed to change and i have problems finding an Hibernate mapping solution.

Table A

a1 (pk)
a2

Table B

b1 (pk, fk on 'A.a1')
b2 (pk)
b3

Table C

c1 (pk, fk on 'B.b1')
c2 (pk, fk on 'B.b2')
c3 (pk)
c4

Table D

d1 (pk)
d2 (pk, fk on 'A.a1')
d3 (fk on 'C.c2')
d4 (fk on 'C.c3')
d5

Now the problem i got is on theb level of column d2 of Table D which is a part of composite key and also a part of foreign key on Table C

In Hibernate I did this

@Embeddable
public class TableDId {
    private Long d1;
    private TableA d2;

    @Column(name="d1")
    public Long getD1() {
        return this.d1;
    }

    @ManyToOne
    @JoinColumn(name="d2")
    public Long getD2() {
        return this.d2;
    }
    // Setters
}


@Entity
public class TableD {
    private TableDId id;
    private TableC tableC;

    @EmbeddedId @GeneratedValue(strategy = GenerationType.AUTO)    
    public TableDId getId() {
        return this.id;
    }

    @ManyToOne
    @JoinColumns({
        @JoinColumn(name="id.d2", referencedColumnName="c1"),
        @JoinColumn(name="d3", referencedColumnName="c2"),
        @JoinColumn(name="d4", referencedColumnName="c3")
    })
    public TableC getTableC() {
        return tableC;
    }

    // Setters
}

As you can guess that doesn’t work, i got an Hibernate error when saving a new TableD

java.sql.BatchUpdateException: Unknown column 'id.d2' in 'field list'

Can anyone propose a working solution?

Thanx a lot.

  • 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-24T10:32:55+00:00Added an answer on May 24, 2026 at 10:32 am

    You should post all annotated classes. Are you using in all classes @EmbeddedId or do you also use IdClass?
    You should have a look at the JPA 2 specification in the “Mapping of Derived Identities” section. I reckon you need to use @MapsId on the association. Or place the @Id annotation on the association as well, but this will depend on how exactly you mapped the other classes.

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

Sidebar

Related Questions

i have got a problem with my SQL Statement: Table structure: CREATE TABLE tags
I've got a problem with foreign key. This is my DB structure (simplified): Table
I've got this really basic table structure: dbo.tblCategory dbo.tblQuestion (many to one relationship to
I've got a table structure I'm not really certain of how to create the
I have a table structure looking something like this. One outer table and in
I have a table called user_details this table has got morethan 100k user details
I tried this: ALTER TABLE My.Table DROP MyField and got this error: -MyField is
I've got a table of student information in MySQL that looks like this (simplified):
So, here's the problem (it's probably an easy one :P) This is my table
I've got a table structure that can be summarized as follows: pagegroup * pagegroupid

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.