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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:10:53+00:00 2026-06-18T02:10:53+00:00

I have the following Entity in hibernate, using JPA annotations @Entity @IdClass(PurchaseCounter.PurchaseCounterPK.class) @Table(name =

  • 0

I have the following Entity in hibernate, using JPA annotations

@Entity
@IdClass(PurchaseCounter.PurchaseCounterPK.class)
@Table(name = "customer_purchases_counter")
public class PurchaseCounter {


    public static class PurchaseCounterPK implements Serializable {

        Integer customerId;
        Integer purchaseId;

        public PurchaseCounterPK(Integer customerId, Integer purchaseId) {
            this.customerId = customerId;
            this.purchaseId = purchaseId;
        }


        public Integer getCustomerId() {
            return customerId;
        }

        public void setCustomerId(Integer customerId) {
            this.customerId = customerId;
        }

        public Integer getPurchaseId() {
            return purchaseId;
        }

        public void setPurchaseId(Integer purchaseId) {
            this.purchaseId = purchaseId;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            PurchaseCounterPK that = (PurchaseCounterPK) o;

            if (customerId != null ? !customerId.equals(that.customerId) : that.customerId != null) return false;
            if (purchaseId != null ? !purchaseId.equals(that.purchaseId) : that.purchaseId != null) return false;

            return true;
        }

        @Override
        public int hashCode() {
            int result = customerId != null ? customerId.hashCode() : 0;
            result = 31 * result + (purchaseId != null ? purchaseId.hashCode() : 0);
            return result;
        }
    }


    Integer customerId;
    Integer purchaseId;
    Integer count = 0;

    @Id
    @Column(name = "customer_id")
    public Integer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Integer customerId) {
        this.customerId = customerId;
    }

    @Id
    @Column(name = "purchase_id")
    public Integer getPurchaseId() {
        return purchaseId;
    }

    public void setPurchaseId(Integer purchaseId) {
        this.purchaseId = purchaseId;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }
}

when I do a query using Criteria and using purchaseId and customerId as Restriction.eq filters, that’s the query that gets generated:

select this_.customerId as customerId137_0_, this_.purchaseId as purchaseId137_0_, this_.count as count137_0_ from customer_purchases_counter this_ where this_.purchaseId=? and this_.customerId=?

that of course is wrong because the fields customerId and purchaseId are not renamed to their names that I specified using @Column????

  • 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-18T02:10:54+00:00Added an answer on June 18, 2026 at 2:10 am

    Mapping seems to be correct. This is likely occurrence of HHH-4256 (Hibernate does not honor @Column(name=…) annotation with IdClass) . If so, then updating to the newer version of Hibernate offers solution.

    Also according bug report using @Column annotation in IdClass is workaround.

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

Sidebar

Related Questions

I have the following mapping: @Entity @Table(name = Prequalifications) public class Prequalification implements Serializable
I have an entity mapped as following: @Entity @Table(name = Groups) @IdClass(value = GroupId.class)
I have the following @OneToOne relation: @Entity @Table(name=USER) public class User implements Serializable{ private
I have the following class: @Entity @Table(name = USERS) public class User { private
I have the following entity with the following relation: @Entity @Table(name = bpr_user) public
I have the following entity class : @Entity @Table(name = THE_TREE, catalog = ,
I have the following entities: @Entity public class Owner{ @Id @Column(name = OWNER_ID) @OneToMany()
I have the following mapping @Entity @SequenceGenerator(name=sacpSequenceGenerator, sequenceName=SACP_SEQ) public class Sacp { private Integer
Say, I have following entities: @Entity public class A { @Id @GeneratedValue private Long
I have a JPA entity bean similar to the following: @Entity class License {

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.