-->
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.  [ 3 posts ] 
Author Message
 Post subject: Does createAlias chaining require same domain id types
PostPosted: Thu Feb 16, 2017 6:00 am 
Newbie

Joined: Thu Feb 16, 2017 5:33 am
Posts: 2
Does createAlias chaining require that all domain objects down the chain have same id types

I have this in the code

Code:
crit.createAlias("claim", "cl")
.createAlias("cl.episode", "ep")
.createAlias("ep.referral", "rf")
.createAlias("rf.patient", "pt")
.createAlias("pt.person", "per");


org.hibernate.TypeMismatchException exception is thrown with the message Provided id of the wrong type. Expected: class java.lang.Long, got class java.lang.Integer when crit.list(); method is called.

When I commented out:

Code:
crit.createAlias("claim", "cl")
.createAlias("cl.episode", "ep")
.createAlias("ep.referral", "rf")
.createAlias("rf.patient", "pt")
.createAlias("pt.person", "per");


no exception is thrown.

When I have it thus

Code:
crit.createAlias("claim", "cl")
.createAlias("cl.episode", "ep");
//.createAlias("ep.referral", "rf")
//.createAlias("rf.patient", "pt")
// .createAlias("pt.person", "per");


It worked, however with this:

Code:
crit.createAlias("claim", "cl")
.createAlias("cl.episode", "ep")
.createAlias("ep.referral", "rf");
//.createAlias("rf.patient", "pt")
// .createAlias("pt.person", "per");


The id types of the domains

Remittance - Long
Claim - Long
Episode - Integer
Referral - Integer
Patient - Integer
Person - Integer.


Top
 Profile  
 
 Post subject: Re: Does createAlias chaining require same domain id types
PostPosted: Thu Feb 16, 2017 6:18 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
And on the database side, does the PK match the types of the FK?

Anyway, even if this is a bug, the legacy Criteria is deprecated so no further development will be done in this area. You need to switch to JPA Criteria API and see if the problem still replicates.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Does createAlias chaining require same domain id types
PostPosted: Thu Feb 16, 2017 6:59 am 
Newbie

Joined: Thu Feb 16, 2017 5:33 am
Posts: 2
vlad wrote:
And on the database side, does the PK match the types of the FK?

Anyway, even if this is a bug, the legacy Criteria is deprecated so no further development will be done in this area. You need to switch to JPA Criteria API and see if the problem still replicates.



Thank you very much, I suppose the Pks match the FKs, I will confirm if it doesn't.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.