There were other recent discussions about ways to customize relationship
fetching (e.g.
http://objectstyle.org/cayenne/lists/cayenne-user/2004/10/0083.html). So
this is the area I am definitely looking to. There can be some interesting
possibilities...
What you suggest is API for configuration of each individual DataObject
instance. This offers maximum flexibility, but is not modeler-friendly and
requires extra attention to be paid to the object lifecycle (so that your
filter actually takes effect). BTW, your suggestion can be implemented
with current Cayenne, using custom DataObject superclass and custom class
generation template.
I was thinking about another approach - a relationship-level qualifier
(like the one we now allow for entities), or even better - a full-blown
SelectQuery to fetch a relationship (so that ordering and other parameters
can be specified as well). However it is too limiting, as such
qualifier/query will be shared by all instances of a particular entity,
and customizing it at the object level is not easy.
Looking for good ways to merge the two...
Also note that all the solutions above (including entity qualifier) have
one big hole - "filters" work on select, but not on save. So it is
possible to create and save objects for a given entity or relationship,
that will not be fetched next time such entity/relationship is accessed.
It is currently a user responsibility to prevent this from happenning.
Andrus
P.S. I guess opening a new issue in JIRA makes sense - looks like we have
a few things to discuss here...
> I've got a simular problem:
>
> Every user has a role and in this role I can specify
> which part of an order is invisible for this user.
>
> example:
>
> every order has a set of events for tracing the lifecycle
> but not all events should be visible for all users. So I need
> to filter the events in a way, that every user only sees
> the right events ...
>
> my idea
> -----------------------------------
> in CayenneDataObject:
>
> public void setFilter(String relation, Expression filter)
> -----------------------------------
>
> does this make sense? and if yes should I raise feature request?
>
This archive was generated by hypermail 2.0.0 : Mon Oct 18 2004 - 15:55:46 EDT