I am still confused by this too.
Say i have a 1:n mapping between Manager and Employee.
I want to query using ODMG to say
"select all Managers (and their Employees) where Manager.department=blah AND
Employee.status=fulltime"

I did this using a query customizer for static queries (eg
Employee.deleted=false).
I never worked out how to do dynamicly though.  My (bodge) solution was to
load the Managers with all their Employees, and then remove any Employees
from the collection that didnt match my criteria.

I can see an obvious problem with this querying - if you materialise a
Manager, all Employees relating to it should be materialised, as say for
example you do a markDirty on the Manager object matching the above
criteria, all the Employees not matching status=fulltime would not be in the
collection when it's written, so would be lost.

Still, for read only (eg web interfaces like JSP using taglibs) it would be
very useful to be able to do these queries.

Daniel.

----- Original Message ----- 
From: "Brian McCallister" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Friday, December 19, 2003 3:27 PM
Subject: Re: How to pass dynamic attribute values to
QueryCustomizerImplementations


> Saw your original message and am thinking about this one.
>
> Any chance you can post specifics?
>
> Does value need to change while running, or is it just dependent upon
> something at load time?
>
> -Brian
>
> On Fri, 2003-12-19 at 10:09, Guido Beutler wrote:
> > Hello,
> >
> > This is a repost with a better subject, hoping to get a hint.
> >
> > I build a custom QueryCustomizer implementation to restrict the
> > retrieved values of a collection to a known primary key.
> > I saw that I could add attributes at the deployment descriptor but the
> > value of the
> > primary key changes dynamically during my application.
> >
> > My sample:
> >
> >    public Query customizeQuery(Object anObject, PersistenceBroker
> > aBroker, CollectionDescriptor aCod, QueryByCriteria aQuery)
> >    {
> >       aQuery.getCriteria().addEqualTo("field","value");
> >        return aQuery;
> >    }
> >
> > The "value" should change dynamically. Is there really no way to pass
> > additional dynamic arguments to the implementation?
> > IA Simple workaround is to use System properties but of course this just
> > a hack for a test case. It's not thread save, it's slow
> > etc.
> > I found no way to find out where the current query came from to build
> > sonething like a callback. Extending the Query implementation by
> > a user object would be a solution buit this modification shouldn't be
> > done without consulting the OJB crew.
> > Implementing a user object might be difficult because the querry which
> > is passed to the QueryCustomizer  is generated by OJB and is
> > not directly coming from my code. So a modified Query would mean that
> > the user object must be passed around by OJB Broker.
> > I still think that I miss something.
> >
> > best regards,
> >
> > Guido
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to