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 Gu...@gxs.com on 2004/09/21 14:52:25 UTC

OJB queries

Hi

I am Trying to build a search facility for an already existing database
using OJB. One of the critical quality aspect is performance of this search
interface. For this purpose I've developed a prototype and using OQL to run
the queries.

Can somebody help me on following 2 questions :

1. For retrieving the referenced object OJB is not using subqueries and it
generated a huge "IN" clause and passes all the ids generated by the base
query: for example Lets say I have two entities : entity A and  entity B,
where A contains a list of B's. When I search on A and try to retrieve  the
list of B's (using  auto-retrieve="true") OJB generates 2 queries where
first it queries all the ids of A and then these ids are passed in the
second query's "IN" clause ( In some cases more than 2 if the ids returned
from A are more than a specific number.) This becomes a performence issue if
I have many referenced entity in a given entity. Is   there a way to change
this behavior.

2. Is it necessary to have a primary key defined for each of the persistence
capable objects.

Regards
Tarun Gupta




Re: OJB queries

Posted by Stijn de Witt <St...@bergland-it.nl>.

GuptaTTG@gxs.com wrote:

>Hi
>
>I am Trying to build a search facility for an already existing database
>using OJB. One of the critical quality aspect is performance of this search
>interface. For this purpose I've developed a prototype and using OQL to run
>the queries.
>
>Can somebody help me on following 2 questions :
>
>1. For retrieving the referenced object OJB is not using subqueries and it
>generated a huge "IN" clause and passes all the ids generated by the base
>query: for example Lets say I have two entities : entity A and  entity B,
>where A contains a list of B's. When I search on A and try to retrieve  the
>list of B's (using  auto-retrieve="true") OJB generates 2 queries where
>first it queries all the ids of A and then these ids are passed in the
>second query's "IN" clause ( In some cases more than 2 if the ids returned
>from A are more than a specific number.) This becomes a performence issue if
>I have many referenced entity in a given entity. Is   there a way to change
>this behavior.
>  
>
I think you should look at proxies. They allow you to have the object 
only load the id. The rest of the object is not loaded until you 
actually try to access the object.

It might also be worth to rewrite your query using a report query. This 
way you  get 'record(s)' back instead of object(s). This allow you to 
only retrieve the fields you really are interested in.

>2. Is it necessary to have a primary key defined for each of the persistence
>capable objects.
>  
>
Don't know what you mean. In general, eacht TABLE needs a primary key. 
If you map a class to a table, then the object CAN also contain that id, 
and getId() and setId() methods. You can also use anonymous id, in that 
case the id is only 'visible' in the table, not on your object.

Hope it helps,
-Stijn

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