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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:16:19+00:00 2026-06-04T17:16:19+00:00

I am getting error: org.hibernate.TypeMismatchException: Provided id of the wrong type for class BEntity.

  • 0

I am getting error:

org.hibernate.TypeMismatchException: Provided id of the wrong type for class BEntity. Expected: class BEntity, got class AEntity

public class BEntity implements Serializable{
    @Id
    @Column(name = "NUM")
    private String num;

    @Id
    @Column(name = "INIT")
    private String init;

    @Column(name = "V_CNT")
    private Integer vcnt;

   //{{{some column omitted}}}//
}

public class AEntity implements Serializable{

    @Id
    @Column(name = "NUM")
    private String num;

    @Id
    @Column(name = "INIT")
    private String init;

    @OneToOne
    @PrimaryKeyJoinColumns({
        @PrimaryKeyJoinColumn(name="NUM", referencedColumnName="NUM"),
        @PrimaryKeyJoinColumn(name="INIT", referencedColumnName="INIT")
    })
    private BEntity bEntity;
}

HQL query:

String queryString = "FROM AEntity AS A " +
                     "LEFT JOIN A.bEntityAS B " +
                     "WHERE A.INIT||A.NUM IN (:carList) AND A.INIT IN (:initList) AND A.NUM IN (:numberList) " + 
                     "AND B.TRUK_AXL_CNT > 0";

Hibernate gen-code

select aentity0_.NUMBER as NUMBER4_0_, aentity0_.INITIAL as INITIAL4_0_, bentity_p1_.NUMBER as NUMBER5_1_, bentity_p1_.INITIAL as INITIAL5_1_, aentity0_.V_CNT as VCNT3_4_0_, aentity0_.EIN as EIN4_0_, aentity0_.TYP as TYP5_4_0_, aentity0_.TRUK_CNT as TRUK6_4_0_, bentity_p1_.TRUK_AXL_CNT as TRUK3_5_1_ from USR.aentity aentity0_ left outer join USR.bentity_PRIMARY bentity_p1_ on aentity0_.NUMBER=bentity_p1_.NUMBER and aentity0_.INITIAL=bentity_p1_.INITIAL 
where (aentity0_.INITIAL||aentity0_.NUMBER in (?,?,?)) 
and (aentity0_.INITIAL in (?,?,?)) 
and (aentity0_.NUMBER in (?, ?, ?))
and bentity_p1_.TRUK_AXL_CNT>0

When I run the code in SQL Explorer it works only running it in code cause the issue…

  • 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-04T17:16:21+00:00Added an answer on June 4, 2026 at 5:16 pm

    Looks like this is a defect in hibernate version 3.2.6 which is still not resolved. Came across this JIRA.

    Having multiple @Id is supported by Hibernate but seems it fails under one to one mapping, suggested way of resolving this is to use single CompositeKey, which means you create a PK class

    import java.io.Serializable;
    
    import javax.persistence.Column;
    import javax.persistence.Embeddable;
    
    @Embeddable
    public class PKClass implements Serializable {
    
        @Column(name = "NUM")
        private String num;
    
        @Column(name = "INIT")
        private String init;
    
        //gettter setter here
    
    }
    

    then in your Entity use this as the ID

    public class BEntity implements Serializable{
    
        @Id
        private PKClass pkClass = null;
    
        @Column(name = "V_CNT")
        private Integer vcnt;
    
       //{{{some column omitted}}}//
    }
    
    public class AEntity implements Serializable{
    
        @Id
        private PKClass pkClass = null;
    
        @OneToOne
        @PrimaryKeyJoinColumns({
            @PrimaryKeyJoinColumn(name="NUM", referencedColumnName="NUM"),
            @PrimaryKeyJoinColumn(name="INIT", referencedColumnName="INIT")
        })
        private BEntity bEntity;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this Hibernate error: org.hibernate.MappingException: Could not determine type for: a.b.c.Results$BusinessDate, for columns:
I am getting the following error org.springframework.orm.hibernate3.HibernateSystemException: could not deserialize; nested exception is org.hibernate.type.SerializationException:
Im getting following error while running the query. org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'LIMIT' near
Any ideas as to why I'd be getting this error: nested exception is org.hibernate.NonUniqueObjectException:
I am getting the following error Exception in thread main java.lang.ClassCastException: org.hibernate.impl.SessionFactoryImpl cannot be
Getting a strange error on bundle install.. bundle install Fetching gem metadata from http://rubygems.org/.....
I'm trying to get http://www.gelens.org/code/gevent-websocket/ running and keep getting the following error. socket_id=1 already
This is a spring mvc application using IntelliJ. I'm getting this error: org.springframework.orm.hibernate3.HibernateSystemException: Unknown
I am getting an error in hibernate and failing to know its origin stack
@Autowiring is not working on fields and am getting: Error: SEVERE: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error

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.