-->
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.  [ 5 posts ] 
Author Message
 Post subject: !No! SELECT(sub_query) in Hibernate ?
PostPosted: Mon Sep 12, 2005 11:05 am 
Newbie

Joined: Fri Jun 24, 2005 5:34 am
Posts: 18
Hy,

just a question :

Why this Query is not correctly rendered by Hibernate ? :

String req = "select store.id, " +
" (select count(quantity) FROM TItems i_2 " +
" WHERE i_2.store.id = store.id" +
" AND i_2.recall.id = :id "
+ " AND i_2.quantity = 0), " +
" (select count(quantity) FROM TItems i_3 " +
" WHERE i_3.store.id = store.id" +
" AND i_3.recall.id = :id "
+ " AND i_3.quantity > 0), 1 "
+ "FROM TStore store "
+ "WHERE EXISTS ( select items.store.id "
+ " FROM TItems items "
+ " WHERE items.store.id = store.id"
+ " AND items.recall.id = :id )" ;

Query q;
List list;

// getting StoreGroupAndCount list.
q = HibernateUtils.getSession().createQuery(req);
q.setLong("id", recall.getId());

list = q.list();





I got :
select tstore0_.StoreID as col_0_0_ from v_Store tstore0_ where exists (select titems1_.StoreID from Recall_Article_Store titems1_ where titems1_.StoreID=tstore0_.StoreID and titems1_.RecallID=?)


!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 11:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
HB 3.1 has some support for select clause subselects.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 2:45 am 
Newbie

Joined: Fri Jun 24, 2005 5:34 am
Posts: 18
damn, so, HB 3.0.5 doesn't support that ? What a mazing :ยง

If I must use a beta version, Hibernate is not the good solution !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 2:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Don't use Hibernate then.


(By the way, I know of no other ORM solution that supports select-clause subselects.)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 2:57 am 
Newbie

Joined: Fri Jun 24, 2005 5:34 am
Posts: 18
I'll use Hibernate, it's help me so many times, so beta version won't stop me ;)

thx gavin for u help :)


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