-->
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: DetachedCriteria Restrcitions.eqProperty missing alias
PostPosted: Fri Apr 15, 2016 10:30 am 
Newbie

Joined: Thu Dec 20, 2012 2:08 am
Posts: 3
Hi!

Tried to make an self join with the same table with the following DetachedCriteria:
Code:
Criteria crit = session.createCriteria(entityType,"resultAlias");
DetachedCriteria subselect = DetachedCriteria.forClass( Produkt.class, "inner" );
            subselect.add( Restrictions.eqProperty( "inner.sub","resultAlias.sub") );
            subselect.add( Restrictions.eqProperty( "inner.kennung", "resultAlias.kennung" );
            subselect.setProjection( Projections.property( "status" ) );
            crit.add( Subqueries.leAll( "0", subselect ) );


Output:
Code:
select ....
from PRODUKT alias_result_ where 0 <= all (select inner_.status as y0_ from PRODUKT inner_ where
(sub=sub) and kennung=kennung);


I am missing the alias at the join !
expected SQL:
Code:
select ....
from PRODUKT alias_result_ where 0 <= all (select inner_.status as y0_ from PRODUKT inner_ where
(alias_result_.sub=inner_.sub) and alias_result_.kennung=inner_.kennung);


I am using hibernate version 3.2.6 what do I wrong ?


Top
 Profile  
 
 Post subject: Re: DetachedCriteria Restrcitions.eqProperty missing alias
PostPosted: Mon Apr 18, 2016 2:06 am 
Newbie

Joined: Thu Dec 20, 2012 2:08 am
Posts: 3
solution (not the best, but works):

Code:
subselect.add( Restrictions.sqlRestriction( "sub = this_.sub and kennung = this_.kennung" ) );


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.