-->
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.  [ 2 posts ] 
Author Message
 Post subject: Criteria - Projections with Restrictions
PostPosted: Tue Mar 29, 2016 9:52 am 
Newbie

Joined: Tue Mar 29, 2016 5:22 am
Posts: 2
Hi, i want to know how i can tell the hibernate API to not use projection aliases for the restrictions in one query.

Example

Code:
ProjectionList colProjection = Projections.projectionList();
List<Criterion> colCriterions = new ArrayList<>();

colProjection.add( Projections.property( "pid" ), "pid" );
colProjection.add( Projections.property( "descr" ), "descr" );

colCriterions.add( Restrictions.eq( "pid", 1l ) )
colCriterions.add( Restrictions.like( "descr", "some text", MatchMode.ANYWHERE ) );

Criteria query = session.createCriteria(Some.class);
query.setProjection( colProjection );
for ( Criterion criteria: colCriterions ) {
    query.add(criteria);
}
query.setResultTransformer( Transformers.aliasToBean(Some.class ) );

List<Some> = query.list();


The example above wont work, because the Restrictions are putting the alias from the Projections into the WHERE-clause of the query.

So, how do Projections and Restrictions get along? Can i turn off the alias using from Projections?


Top
 Profile  
 
 Post subject: Re: Criteria - Projections with Restrictions
PostPosted: Thu Mar 31, 2016 8:39 am 
Newbie

Joined: Tue Mar 29, 2016 5:22 am
Posts: 2
Update

It seems im affected of this Bug: https://hibernate.atlassian.net/browse/HHH-817 as my Version is 3.2.1.
I will upgrade to the latest hibernate 3.6.10 and report the result.


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