Assume the following class:
Code:
class A {
Long id; // PK
Set dates; // Set of Date objects
}
Now say that I want to find all instances of class A that contain dates within a specified period, ie, given two dates, "from" and "to", find all instances of class A whose dates collection contains a date between "from" and "to".class A {
}
Given that my ddl looks like:
Code:
CREATE TABLE A (
id int
);
CREATE TABLE A_dates (
id_of_a int,
date date
);
I would achieve the above requirement in SQL using the following pseudoquery which would list each instance of next to each date it contains:
Code:
SELECT A.id, A_dates.date from A LEFT JOIN A_dates ON A.id = A_date.id_of_a WHERE A.date >= "FROM" and A.date <= "TO";
How could I achieve the same in HQL?
I though of using a filter but it seems to me that you can only filter one particular collection each time so it wouldn't work for my case unless I filtered each instance of A separately which sounds like overkill.
Thanks for your help,
Giorgos