I have a query that gets an entity and joins with its child
associations, but I'm now realizing that I have to filter the entities
in the child associations to ones that fulfill a condition. I looked
through the openjpa doc, but I didn't see an example that looks like
this.
For example, my main entity is "Foo", which has a "one-to-many" for
"Bar" called "childBars".
My initial query was this:
"select foo from packagepath.Foo foo left join fetch foo.childBars
where foo.id=:id".
I now need to do something like this:
"select foo from packagepath.Foo foo left join fetch foo.childBars
where foo.id=:id and
current_date between foo.childBars.startDate and
foo.childBars.endDate"
I thought this would be close, but I'm obviously not referencing the
"startDate" or "endDate" properties of "Bar" correctly (I get an error
about "startDate" not a property of "Foo").
I can do this in SQL, but I'm not sure how this translates to JPQL.