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/18 18:19:48 UTC

How to restrict result of 1:N mappings

Hello,

I've got a 1:N mapping between classes. I would like to restrict the 
entries at the retrieved collection.

I got two Classes A and B with a 1:n mapping between it. B has >17000 
entries so I would like
to restrict the collection to a small set of B's by using the primary 
key of B.
By using a path expression I get the correct A but the collection from A 
to B contains all values of B
not only the ones with the given b.pk .

Could somebody give me a hint where to look at?

Thanks in advance, 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 restrict result of 1:N mappings

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi guido,

the first parmeter passed to customizeQuery is the owner object so you 
can get values from there as well. attributes defined in the repository 
are static.

hth
jakob

Guido Beutler wrote:
> Hi Jakob,
> 
> ok, first QueryCustomizer implementation is working :-)      Thanks!
> 
> Now I got the next question. How should I pass values on the fly to my 
> customizer.
> I would like to restrict the collection to one value and at my test case 
> I already have the
> primary key of the row. But how can I pass this value to my customizer?
> 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. Could somebody give me a 
> aditional hint?
> 
> best regards,
> 
> Guido
> 
> Jakob Braeuchi wrote:
> 
>> hi guido,
>>
>> please have a look at the query customizer.
>>
>> jakob
>>
>> Guido Beutler wrote:
>>
>>> Hello,
>>>
>>> I've got a 1:N mapping between classes. I would like to restrict the 
>>> entries at the retrieved collection.
>>>
>>> I got two Classes A and B with a 1:n mapping between it. B has >17000 
>>> entries so I would like
>>> to restrict the collection to a small set of B's by using the primary 
>>> key of B.
>>> By using a path expression I get the correct A but the collection 
>>> from A to B contains all values of B
>>> not only the ones with the given b.pk .
>>>
>>> Could somebody give me a hint where to look at?
>>>
>>> Thanks in advance, 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 restrict result of 1:N mappings

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

ok, first QueryCustomizer implementation is working :-)      
Thanks!

Now I got the next question. How should I pass values on the fly to my 
customizer.
I would like to restrict the collection to one value and at my test case 
I already have the
primary key of the row. But how can I pass this value to my customizer?
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. Could somebody give me a 
aditional hint?

best regards,

Guido

Jakob Braeuchi wrote:

> hi guido,
>
> please have a look at the query customizer.
>
> jakob
>
> Guido Beutler wrote:
>
>> Hello,
>>
>> I've got a 1:N mapping between classes. I would like to restrict the 
>> entries at the retrieved collection.
>>
>> I got two Classes A and B with a 1:n mapping between it. B has >17000 
>> entries so I would like
>> to restrict the collection to a small set of B's by using the primary 
>> key of B.
>> By using a path expression I get the correct A but the collection 
>> from A to B contains all values of B
>> not only the ones with the given b.pk .
>>
>> Could somebody give me a hint where to look at?
>>
>> Thanks in advance, 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 restrict result of 1:N mappings

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi guido,

please have a look at the query customizer.

jakob

Guido Beutler wrote:

> Hello,
> 
> I've got a 1:N mapping between classes. I would like to restrict the 
> entries at the retrieved collection.
> 
> I got two Classes A and B with a 1:n mapping between it. B has >17000 
> entries so I would like
> to restrict the collection to a small set of B's by using the primary 
> key of B.
> By using a path expression I get the correct A but the collection from A 
> to B contains all values of B
> not only the ones with the given b.pk .
> 
> Could somebody give me a hint where to look at?
> 
> Thanks in advance, 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