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.