Piet Molenaar wrote:

Hi,
First of all, ojb is great and I find great support on this list.

Unfortunately I did not find a solution to the following problem.
At the moment I'm implementing a persistent datalayer for an application that has to perform queries over large sets of data.
I only want to search for id's so I use dynamic proxies, but I don't want to materialize each proxy to query its details.
Now I implemented something like:


for (Iterator iter = myCreatedPersistenceBroker.getIteratorByQuery(someQueryReturningLargeSet);

iter.hasNext(); )
{
java.lang.reflect.Proxy item = (java.lang.reflect.Proxy) iter.next();
IndirectionHandler handler = (IndirectionHandler) item.getInvocationHandler(item);
Object[] values = handler.getIdentity().getPrimaryKeyValues();
if (values[0].equals(theIdSearchedFor) )
{
TargetInterface target = (TargetInterface) item;
}
}


This worked and was in a first test about 5 times faster than querying all materialized proxies but it seems so complicated to me.
Is there a proper way to achieve this using ojb-pb api or am I misunderstanding something completely?

It might be better to use the org.apache.broker.core.proxy.ProxyHelper#getIndirectionHandler method to obtain the indirection handler object (instead of the cast to Proxy and the call to getInvocationHandler). Other than that, this seems to be the easiest way without actually materializing the objects.
If you're needing this often, then you could also wrap this in your own collection class.


Tom


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



Reply via email to