Hi Gildas,

According to me, the two approachs are not compatible.
- If you are trying to get A and B in only one query:
Then the following code
   criteria.addEqualTo("name", 'xxx');
   criteria.addEqualTo("elements.filter", 'yyy');
is the way. And you will get A WITH the filtered collection of B.
And I don't see why you don't want to load the relationship, because
a join query is executed because you want the relationships.
- If you try to avoid unnecessary relationships loading:
Then the proxy is the solution. And in this case the filtering cannot
be done automatically. You have to do it programmatically by adding a method
like
A.getB(int yyy) where you implement your filter.

If you are taking of performance, first do it as simple as possible, then
look if you face performance issues.
Personally, I generally choose the second approach and I use the first one
only in case of performance issues (but only monitoring can say what to do).
Then I have two methods:
A getById(); // criteria.addEqualTo("name", 'xxx') and use proxy
A getByIdWithB(); //   criteria.addEqualTo("name", 'xxx')
criteria.addEqualTo("elements.filter", 'yyy')

Be also aware that caching the objects increases performance.
If B contains rather stable data, then cache them.
A.getB() will then use the cache instead of generating a SQL.

Hope it helps...

David WIESZTAL.


-----Original Message-----
From: LE-QUERE Gildas - REN [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 26, 2004 6:10 PM
To: OJB Users List
Subject: Re: collection loading and filtering


Hi David,

Thanks for your solution with the proxy, I tried it. The relationship is
loaded when I navigate however the elements are not filtered.

When  a proxy is used a proxy instance is set in the relationship attribute.
The proxy instance contains the  criteria to get the collection when the
relationship is navigated,  this criteria is not my criteria to filter the
loading.

The final goal is to get a collection of B where the filter='yyy' and and
the name of the A owner is 'xxx'
like the SQL statement :

select b
    from A (alias) a,  B (alias) b
    where a.name='xxx'
        and b.oid=a.oid
        and b.filter='yyy'

regards

Gildas

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 25, 2004 10:26 AM
Subject: RE: collection loading and filtering


Hi Gildas,

You have to set proxy="true" in your collection descriptor.
Like that the relationship is loaded only if you navigate.

David WIESZTAL.


-----Original Message-----
From: LE-QUERE Gildas - REN [mailto:[EMAIL PROTECTED]
Sent: Monday, October 25, 2004 10:06 AM
To: OJB Users List
Subject: collection loading and filtering


Hi all,

I have un object A referencing � collection with B elements.

A has an attribute 'name' and a relation 'elements', B has an attribute
'filter'.

I want to load  elements where name='xxx' and filter='yyy'.

I use the PersitenceBroker API, here is my request:

   criteria = new Criteria();

   criteria.addEqualTo("name", 'xxx');
   criteria.addEqualTo("elements.filter", 'yyy');

   query = QueryFactory.newQuery(A.class, criteria);

   A a =  (A)broker.getObjectByQuery(query);

With  the relationship  auto-retrieve=true all elements are loaded!

If  auto-retrieve=false the relationship is not loaded.

Is there a solution ?


Thanks

Gildas

---------------------------------------------------------------------
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]

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

Reply via email to