-->
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: Does Hibernate support subquery (subselect) in "FROM" clause
PostPosted: Fri Jun 12, 2009 6:00 am 
Newbie

Joined: Fri Jun 12, 2009 5:51 am
Posts: 3
Hi,

I've searched around for the answer but haven't found any confirmation yet.

One said it may occur only in 'select' & 'where' clauses. https://forum.hibernate.org/viewtopic.php?f=1&t=984148&start=0

If you used it before, please let me know. Thanks!


Top
 Profile  
 
 Post subject: Re: Does Hibernate support subquery (subselect) in "FROM" clause
PostPosted: Fri Jun 12, 2009 9:11 am 
Beginner
Beginner

Joined: Fri Feb 13, 2009 5:27 am
Posts: 36
Location: India
Hi greenfield_sg ,,,,


U can refer the book----> Professional Hibernate page no:-202 for more information

Hql querry may be like this:-

from Group as group where size(group.stories) > (
select avg(size(storygroup.stories)) from Group storygroup)



bye.tc

_________________
parag


Top
 Profile  
 
 Post subject: Re: Does Hibernate support subquery (subselect) in "FROM" clause
PostPosted: Fri Jun 12, 2009 5:49 pm 
Beginner
Beginner

Joined: Mon Jun 01, 2009 5:39 am
Posts: 34
HQL still will NOT support subselect in the from clause.

Among other things it will not support is aliases to computed columns in the select clause, which quite fall under the same category. You cannot do:

Code:
select f(c1, c2, c3) as c from thetable where [some condition on c]


Top
 Profile  
 
 Post subject: Re: Does Hibernate support subquery (subselect) in "FROM" clause
PostPosted: Sat Jun 13, 2009 4:53 am 
Newbie

Joined: Fri Jun 12, 2009 5:51 am
Posts: 3
Thanks fge & parag.gajbhiye...

My query is like this:
------
select A.col1, A.col2, resultList.col1
from table1 as A
outer join ( (select B from table2 as B where [condition]) as resultList )
------

In the hibernate mapping, table B contains A's pk, hence they both can join.
I tried in SQL, it worked (i need to write 1 more line, to specify join on which columns).
But i tried in HQL, it returned error.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.