-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to write HQL for the following question
PostPosted: Wed Oct 22, 2003 3:27 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 11:33 pm
Posts: 38
I have a class Department which is mapped to table department.
class Department {
private long id;
private String name;
private Department parentDept;
private Set subDepts;
}
Department may has zero or one parent department and zero or more sub-departments which are also of Department type. I wanna get the following information, but don't know how to write such kind of HQL. Any help is appreciated !

(1) get all the departments which don't have any sub-department.
from hibernate.Department dept where count(elements(dept.subDepts))=0
(2) get all the departments which don't have parent department.
from hibernate.Department dept where dept.parentDept is null

The (1) hql doesn't work ! It reports "Syntax error or access violation, message from server: "You have an error in your SQL syntax. "


Top
 Profile  
 
 Post subject: HQL statement
PostPosted: Wed Oct 22, 2003 5:09 am 
Newbie

Joined: Tue Aug 26, 2003 10:17 pm
Posts: 5
Hi,

Will this work for the first query ?

from hibernate.Department dept where dept.subDepts.size = 0

"size" property is a special property for collections

Clarence


Top
 Profile  
 
 Post subject: It does not work !
PostPosted: Wed Oct 22, 2003 10:11 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 11:33 pm
Posts: 38
Anybody can help ?
thanks !


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