-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate - CriteriaBuilderImpl - method treat()
PostPosted: Wed Nov 15, 2017 2:28 am 
Newbie

Joined: Wed Nov 15, 2017 2:20 am
Posts: 2
In WildFly 11 Hibernate was updated from 5.0.7.Final to 5.1.10.Final.

In new Hibernate "joins.add( treatAs );" adds extra JOIN to database query, so every row appears twice in result.

Hibernate 5.0.7.Final

public <X, T, V extends T> Join<X, V> treat(Join<X, T> join, Class<V> type) {
return ( (JoinImplementor) join ).treatAs( type );
}

Hibernate 5.1.10.Final

public <X, T, V extends T> Join<X, V> treat(Join<X, T> join, Class<V> type) {
final Set<Join<X, ?>> joins = join.getParent().getJoins();
final Join<X, V> treatAs = ( (JoinImplementor) join ).treatAs( type );
joins.add( treatAs );
return treatAs;
}

Result query:

Hibernate 5.0.7.Final

select internalbl0_.*
from blrecord internalbl0_
inner join blentry entries1_ on internalbl0_.id=entries1_.record_id
where internalbl0_.dtype='1' and entries1_.dtype=$1 and entries1_.value=$2 and internalbl0_.status=$3
group by internalbl0_.id
having count(internalbl0_.id)=1

Hibernate 5.1.10.Final

select internalbl0_.*
from blrecord internalbl0_
inner join blentry entries1_ on internalbl0_.id=entries1_.record_id
inner join blentry entries2_ on internalbl0_.id=entries2_.record_id
where internalbl0_.dtype='1' and entries2_.dtype=$1 and entries2_.value=$2 and internalbl0_.status=$3
group by internalbl0_.id
having count(internalbl0_.id)=1

To make it works I need to add DISTINCT to "count(internalbl0_.id)" => "count(DISTINCT internalbl0_.id)".

Hibernate 5.2.12.Final

I've replaced 5.1.10 with 5.2.12 in WildFly 11 and got the same extra JOIN.

How should I use treat method? May be approach was changed...


Top
 Profile  
 
 Post subject: Re: Hibernate - CriteriaBuilderImpl - method treat()
PostPosted: Wed Nov 15, 2017 4:20 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Sounds like bug. You should add a replicating test case and open a new Jira issue.


Top
 Profile  
 
 Post subject: Re: Hibernate - CriteriaBuilderImpl - method treat()
PostPosted: Wed Nov 15, 2017 9:58 am 
Newbie

Joined: Wed Nov 15, 2017 2:20 am
Posts: 2
I've created an issue https://hibernate.atlassian.net/browse/HHH-12094


Top
 Profile  
 
 Post subject: Re: Hibernate - CriteriaBuilderImpl - method treat()
PostPosted: Wed Nov 15, 2017 12:29 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Thanks.


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