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

  • SEARCH
  • Home
  • 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 8126027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:00:53+00:00 2026-06-06T07:00:53+00:00

I have a JPA/Hibernate object which uses a composite key as the primary key.

  • 0

I have a JPA/Hibernate object which uses a composite key as the primary key. I am trying to read the object from the database and make an update.

Lets say the primary key is (id and name) and the following rows exist in the database.

1   john   London
2   bob    Birmingham
3   Dave   Kent

If i load an object using the key (1,john) then everything works fine. If i load it using the same primary but with a difference case using (1, John) then i get the following exception:

org.hibernate.HibernateException: identifier of an instance of Document was altered from com.myPck.test1.documentsPK[ Id=1, msgOwner=john ] to com.myPck.test1.documentsPK[ Id=1, msgOwner=John ]; 

After i load the row i do update it using JPQL but i dont update any of the primary key columns. Interestingly if i search for a row that does not exist i dont get that exception. It only occurs if i search for a row that does exist but the case used on the key is different from what is actually in the database.

What could be causing this and how do i resolve it?

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-06-06T07:00:54+00:00Added an answer on June 6, 2026 at 7:00 am

    Can you post the code for the Compound Key class that you are using. My guess is that you have a badly implemented equals and hashCode method on the compound primary key class.

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

Sidebar

Related Questions

IN hibernate JPA how can I update of a object? I have one Project
We have a project that uses JPA/Hibernate on the server side, the mapped entity
I have a JPA object which has a many-to-many relationship like this: @Entity public
I have three classes (House, Room, Address) which are persistent (Mapped with JPA/Hibernate) @Entity
I have a Spring/JPA/Hibernate application and am trying to get it to pass my
We have some legacy database mappings in GORM and several have a primary key
I have a user object represented in JPA which has specific sub-types. Eg, think
I'm using Hibernate/JPA and have an @Entity object called Order, pointing at a MySQL
I have a problem with querying Derby database. I am using Hibernate with JPA.
I've been able to have JPA/Hibernate to replicate the ON DELETE CASCADE functionality successfully

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.