-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: TypeMismatchError for entities with same keys on find
PostPosted: Wed Apr 26, 2017 12:04 pm 
Newbie

Joined: Wed Apr 26, 2017 11:20 am
Posts: 4
Hi,
We recently migrated to Hibernate 4.2.21 release from open jpa as JPA provider. We observed while migration that if the composite keys of two different tables are same, we cannot use different generated PK classes for different tables. For example,

TableA entity has composite key a,b, for which TableAPK gets generated.

TableB entity has composite key a,b, for which TableBPK gets generated.

If we use entityManager.find, we get a TypeMismatch exception stating that Provided Id was TableBPK while it expected TableAPK. The issue can be resolved if we delete TableBPK and have TableB refer to TableAPK as embedded id.

We use eclipse / RAD to generate the entities from tables and making these manual changes does not seem right when this was working in open JPA. Not sure if there is a bug in hibernate to handle such a scenario or it is done on purpose to promote using only single type of key. I understand the rationale behind it, but still wanted to understand if there is an alternate way.

If you need more details on what I am referring to , refer to an old stack overflow post below.

http://stackoverflow.com/questions/1616 ... ue-on-read


Top
 Profile  
 
 Post subject: Re: TypeMismatchError for entities with same keys on find
PostPosted: Mon May 01, 2017 3:11 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Try to replicate it with Hibernate 5.2 and see if it works there. Hibernate 4.2 is quite old and no more development is done on that branch.


Top
 Profile  
 
 Post subject: Re: TypeMismatchError for entities with same keys on find
PostPosted: Tue May 02, 2017 7:41 am 
Newbie

Joined: Wed Apr 26, 2017 11:20 am
Posts: 4
Unfortunately , we are working on WebSphere Application Server 8.5.5 with JPA 2.0 specification support and hibernate 4.2.21 was the last version which supported JPA 2.0. Would 5.2 work on JPA 2.0 specification as well ?


Top
 Profile  
 
 Post subject: Re: TypeMismatchError for entities with same keys on find
PostPosted: Tue May 02, 2017 8:17 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Hibernate 5.2 supports JPA 2.1 as well as older JPA spec versions too.


Top
 Profile  
 
 Post subject: Re: TypeMismatchError for entities with same keys on find
PostPosted: Wed May 03, 2017 1:21 pm 
Newbie

Joined: Wed Apr 26, 2017 11:20 am
Posts: 4
Does 5.2 version use Java 8 ? Our application is using Java 7. Any lower supportable version which has Java 7 compatibility ?


Top
 Profile  
 
 Post subject: Re: TypeMismatchError for entities with same keys on find
PostPosted: Wed May 03, 2017 1:34 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Hibernate 5.2 uses Java 1.8. For Java 1.7, you have to use Hibernate 5.1 or below.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.