You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Guido Beutler <gu...@hrs.de> on 2003/12/19 16:09:17 UTC

How to pass dynamic attribute values to QueryCustomizer Implementations

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: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: How to pass dynamic attribute values to QueryCustomizer Implementations

Posted by Guido Beutler <gu...@hrs.de>.
Hello,

I'm a bit restricted in posting original code but I'll do my best :-)

Ok.



Brian McCallister wrote:

>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?
>
>  
>
at runtime and that is the main problem. During load time I could solve 
by using the attributes at the repository.
I have two classes A and B and A has a 1:n relationshop to B.

<class-descriptor class="A" table="A">
   <field-descriptor id="1"
      name="a_key"
      column="a_key"
      jdbc-type="INTEGER"
   />
   <collection-descriptor name="b_col" element-class-ref="B" 
auto-retrieve="true" auto-update="false" auto-delete="false" 
proxy="false" refresh="false">
      <inverse-foreignkey field-id-ref="2"/>
      <query-customizer
      class="QueryCustomizerFilterImpl">
          <attribute
              attribute-name="attr1"
              attribute-value="value1"
          />
      </query-customizer>
   </collection-descriptor>
</class-descriptor>

<class-descriptor class="B" table="B">
   <field-descriptor id="1"
      name="b_key"
      column="b_key"
      jdbc-type="INTEGER"
      primarykey="true"
      autoincrement="false"
   />
   <field-descriptor id="2"
      name="a_key"
      column="a_key"
      jdbc-type="INTEGER"
      primarykey="true"
      autoincrement="false"
   />
</class-descriptor>



         Criteria crit = new Criteria();
         crit.addEqualTo("key", "value1");

         Criteria crit2 = new Criteria();
         crit2.addEqualTo("b_col.b_key", "pk_value_of_B");

        Criteria crit3 = new Criteria();
         crit3.addAndCriteria(crit);
         crit3.addAndCriteria(crit2);

         Query q = QueryFactory.newQuery(A.class, crit3);
         Collection results = broker.getCollectionByQuery(q);

I would like to get a collection a.b_col which contains only the 
elements of B which has the primary key "pk_value_of_B" not ALL
values. The query from above gives the correct instance of A but the 
collection is filled with all existing b which are very much.
So I build a QueryCustomizer where I can add the missing select criteria 
to the query which was build from OJB to load ALL b.

   public Query customizeQuery(Object anObject, PersistenceBroker 
aBroker, CollectionDescriptor aCod, QueryByCriteria aQuery)
   {
      aQuery.getCriteria().addEqualTo("b_key","pk_value_of_B");
       return aQuery;
   }

My problem is how to get the "pk_value_of_B" to the QueryCustomizer 
instance. The QueryCustomizer instance is constructed by OJB
so the default constructor is called, no way to pass a argument with my 
pk value. After that OJB calls the customizeQuery method and again
it looks like there is no way to get my key in there.

Hope this is more readable and a bit more detailed.

best regards,

Guido

>-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: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>  
>


Re: How to pass dynamic attribute values to QueryCustomizerImplementations

Posted by Guido Beutler <gu...@hrs.de>.
Daniel Perry wrote:

>Sorry, i didn't mean i was confused by your mail, i mean i am in the same
>boat!
>
>Are you using ODMG or PB or JDO?
>  
>
PB

>I believe that using PB (and the example i gave before) you can do somthing
>like:
>
>Criteria crit = new Criteria();
>crit.addLike("department", "blah");
>crit.addLike("employees.status", "fulltime")
>Query qry = new QueryByCriteria(Manager.class, crit);
>
>Could you use somthing like this to query on the collection?
>Build an or criteria with things like:
>crit.addEquals("employees.oid", id1)
>crit.addEquals("employees.oid", id2)
>crit.addEquals("employees.oid", id3)
>
>How would you do this same query using ODMG? or even, can you do this with
>ODMG?
>  
>
No because the ODMB implementation of OJB doesn't support the path like 
queries.

>I tried things like
>"where department=$1 and employee.status=$2"
>but it didnt work.
>
>  
>
Yes won't works see: http://db.apache.org/ojb/status.html

best regards,

Guido

>Daniel.
>
>
>----- Original Message ----- 
>From: "Guido Beutler" <gu...@hrs.de>
>To: "OJB Users List" <oj...@db.apache.org>
>Sent: Friday, December 19, 2003 4:07 PM
>Subject: Re: How to pass dynamic attribute values to
>QueryCustomizerImplementations
>
>
>  
>
>>Hello,
>>
>>for a more detailed description pleas look at my other mail.
>>Daniel Perry wrote:
>>
>>    
>>
>>>I am still confused by this too.
>>>
>>>
>>>      
>>>
>>sorry!
>>
>>    
>>
>>>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"
>>>
>>>
>>>
>>>      
>>>
>>OK then you get a filled collection with all fulltime Employee in there.
>>
>>    
>>
>>>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.
>>    
>>
>>>      
>>>
>>You're right but lets say youre loading >17000 Employees, this may tke a
>>while ;-)
>>I already know that I would need only 1 to 5 so removing them would work
>>but not really is a solution (in my case).
>>
>>    
>>
>>>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.
>>>
>>>
>>>      
>>>
>>Yes, I'm only doing selects and for performance of my application this
>>would be _very_ usefull.
>>For me OJB needs >30s to build the collection
>>
>>best regards,
>>
>>Gudio
>>
>>    
>>
>>>Daniel.
>>>
>>>----- Original Message ----- 
>>>From: "Brian McCallister" <mc...@forthillcompany.com>
>>>To: "OJB Users List" <oj...@db.apache.org>
>>>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: ojb-user-unsubscribe@db.apache.org
>>>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>>
>>>      
>>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>  
>


Re: How to pass dynamic attribute values to QueryCustomizerImplementations

Posted by Daniel Perry <d....@netcase.co.uk>.
Sorry, i didn't mean i was confused by your mail, i mean i am in the same
boat!

Are you using ODMG or PB or JDO?

I believe that using PB (and the example i gave before) you can do somthing
like:

Criteria crit = new Criteria();
crit.addLike("department", "blah");
crit.addLike("employees.status", "fulltime")
Query qry = new QueryByCriteria(Manager.class, crit);

Could you use somthing like this to query on the collection?
Build an or criteria with things like:
crit.addEquals("employees.oid", id1)
crit.addEquals("employees.oid", id2)
crit.addEquals("employees.oid", id3)

How would you do this same query using ODMG? or even, can you do this with
ODMG?
I tried things like
"where department=$1 and employee.status=$2"
but it didnt work.

Daniel.


----- Original Message ----- 
From: "Guido Beutler" <gu...@hrs.de>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Friday, December 19, 2003 4:07 PM
Subject: Re: How to pass dynamic attribute values to
QueryCustomizerImplementations


> Hello,
>
> for a more detailed description pleas look at my other mail.
> Daniel Perry wrote:
>
> >I am still confused by this too.
> >
> >
> sorry!
>
> >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"
> >
> >
> >
> OK then you get a filled collection with all fulltime Employee in there.
>
> >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.
> >
> >
> You're right but lets say youre loading >17000 Employees, this may tke a
> while ;-)
> I already know that I would need only 1 to 5 so removing them would work
> but not really is a solution (in my case).
>
> >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.
> >
> >
> Yes, I'm only doing selects and for performance of my application this
> would be _very_ usefull.
> For me OJB needs >30s to build the collection
>
> best regards,
>
> Gudio
>
> >Daniel.
> >
> >----- Original Message ----- 
> >From: "Brian McCallister" <mc...@forthillcompany.com>
> >To: "OJB Users List" <oj...@db.apache.org>
> >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: ojb-user-unsubscribe@db.apache.org
> >>>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>>
> >>>
> >>>
> >>>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >>For additional commands, e-mail: ojb-user-help@db.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> >For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
> >
> >
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: How to pass dynamic attribute values to QueryCustomizerImplementations

Posted by Guido Beutler <gu...@hrs.de>.
Hello,

for a more detailed description pleas look at my other mail.
Daniel Perry wrote:

>I am still confused by this too.
>  
>
sorry!

>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"
>
>  
>
OK then you get a filled collection with all fulltime Employee in there.

>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.
>  
>
You're right but lets say youre loading >17000 Employees, this may tke a 
while ;-)
I already know that I would need only 1 to 5 so removing them would work 
but not really is a solution (in my case).

>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.
>  
>
Yes, I'm only doing selects and for performance of my application this 
would be _very_ usefull.
For me OJB needs >30s to build the collection

best regards,

Gudio

>Daniel.
>
>----- Original Message ----- 
>From: "Brian McCallister" <mc...@forthillcompany.com>
>To: "OJB Users List" <oj...@db.apache.org>
>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: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>  
>


Re: How to pass dynamic attribute values to QueryCustomizerImplementations

Posted by Daniel Perry <d....@netcase.co.uk>.
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" <mc...@forthillcompany.com>
To: "OJB Users List" <oj...@db.apache.org>
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: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: How to pass dynamic attribute values to QueryCustomizer Implementations

Posted by Brian McCallister <mc...@forthillcompany.com>.
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: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org