-->
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.  [ 1 post ] 
Author Message
 Post subject: Query language and Sets
PostPosted: Sat May 01, 2010 2:06 pm 
Newbie

Joined: Sat May 01, 2010 1:27 pm
Posts: 2
Hi,

I have to classes: Car class and Person class.
A Person can have many cars but a car can be only owned by one person.

Code:
Class Person {
  Set cars = new HashSet(0);
...
}


Mapping file:
Code:
        <set name="cars" inverse="true" lazy="true" table="CAR" fetch="select">
            <key>
                <column name="PERSON_ID" length="10" not-null="true" />
            </key>
            <one-to-many class="negocio.Car" />
        </set>



I would like to build a Hibernate query to fetch a list o people who haven't got any car. I mean, something like:
Code:
FROM Person p WHERE p.cars IS NULL

or
Code:
FROM Person p WHERE p.cars.size() = 0


Any idea?
Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.