-->
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: Query by Criteria and testing against empty collections
PostPosted: Tue Mar 22, 2005 12:35 pm 
Newbie

Joined: Mon Mar 21, 2005 12:52 pm
Posts: 11
Location: Chicago, Il
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.8

Mapping documents:
<class our.class
proxy=our.class
table class>
<property name="objOid" type="java.lang.Long" column="obj_oid">
<many-to-one name="parent"
class="our.class" column="class_parent_oid" />
<bag name="subclass" inverse="true" lazy="true">
<key column="class_parent_oid"/>
<one-to-many class="our.class"/>
</bag>
</class>

Name and version of the database you are using:
Postgres 7.4

This question seems to be avoided quite a bit, as I have been unable to unearth a similar question that has an answer. What I want to know is whether I can add an expression to a QBC I am doing on class that will only give me class.

In sql, I could pull of the query as

select cl.* from class cl where (select count(*) from class where class_parent_oid=cl.obj_oid) <> 0 and cl.class_parent_oid is null;

So is there a test for collection size in the criteria api, or is there a way to pull of the same query I just outlined?

-Andy

_________________
where's my coffee mug?


Top
 Profile  
 
 Post subject: addl
PostPosted: Tue Mar 22, 2005 2:25 pm 
Newbie

Joined: Mon Mar 21, 2005 12:52 pm
Posts: 11
Location: Chicago, Il
using createQuery( "select clazz from our.class clazz where size(clazz.subclass) > 0") works.

I would still like to know if QBC can be used for the same, though

_________________
where's my coffee mug?


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.