hibernate criteria with relations
I'm trying to make a criteria in hibernate or sql/hql query, but I don't succeed.
This is the situation:
there are 2 tables: A and B with a 1:n relationship (so A can have multiple B's).
In B there is a foreign key to A (FK_A_ID, so with the ID of A) and a date field.
I would like to get all ID's of A, witch have a date that is not from this year (2011).
Example: B has 5 records :
ID FK_A_ID date
1 1 01-01-2011
2 1 30-12-2010
3 2 30-12-2010
4 3 30-12-2010
5 4 01-01-2010
I would like to create a criteria (or sql/hql query) which gives me the ID's of A (or the FK_A_ID in B) for the records of B that have no date of this year.
So in this example I would like to retrieve the FK_A_ID's 2 and 3, as A has a record in B of this year for ID's 1 and 4 of A.
Suppose that A has no B's (and so no records in B of this year), then that ID of A should also be selected.
Can anyone help me with this one?