You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by David Goodenough <da...@btconnect.com> on 2008/12/23 13:10:57 UTC

Is there an (Open)JPA way of ...

doing the equivalent of an SQL view?

I realise that this may be a generic JPA question rather than a specifically
OpenJPA one, but there are some JPA experts around here who I sure will
know if anyone does.

I am not looking for the kind of thing that can be done with foreign
keys, I am looking for more complicated relationships.  

Take for instance date ranges.  I have a bunch of entries which have
date stamps in them, and I want to be able to find all the entries which
fall within a date range, NOT by doing a query, but rather in the same
way that foreign keys are resolved, i.e. I get a List of objects as part of
another object.

So for instance I might have a Period class, and I want to have those
entries (part of a much larger list) which fall within the date range covered
by the Period object, available as a List of entries within that Period 
object?

I suppose this would logically be an attribute of @OneToMany, although
as Annotations only take compile time constants as attribute values it would 
not be possible to relate this to the range in the Period object.

Looking to the future, it would probably best be expressed using the
Criteria API.

Any thoughts?

David