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 Florin Pop <Fl...@siveco.ro> on 2003/11/04 11:53:16 UTC

Loading an object

Hi *,

which is the recomended way of loading ann object from the repository when
the primary key is known.
 I tried:

        Criteria crit = new Criteria();
        crit.addEqualTo("id", new Long(PERSON_ID));
        Query query = new QueryByCriteria(Person.class, crit);
        Person person = (Person) broker.getObjectByQuery(query);

but it works very slow, 6-8 times slower than in Hibernate: 
	Person person = (Person) session.load(Person.class, new
Long(PERSON_ID)); 

Is there another way for doing this in OJB? 

Thanks,

Florin

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


Re: Loading an object

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Florin,

Florin Pop wrote:
> Hi *,
> 
> which is the recomended way of loading ann object from the repository when
> the primary key is known.
>  I tried:
> 
>         Criteria crit = new Criteria();
>         crit.addEqualTo("id", new Long(PERSON_ID));
>         Query query = new QueryByCriteria(Person.class, crit);
>         Person person = (Person) broker.getObjectByQuery(query);
> 
> but it works very slow, 6-8 times slower than in Hibernate: 
> 	Person person = (Person) session.load(Person.class, new
> Long(PERSON_ID)); 
> 
You can't compare these methods

getObjectByQuery does at all event perform an sql query
and then analyse ResultSet if object needs materialization
or could be found in cache

session.load(Person.class, new Long(PERSON_ID));
does first look in the cache for an object with
given UID and if not found perform an DB lookup

A similar method in PB-api is
getObjectByIdentity(Identity id)

regards,
Armin


> Is there another way for doing this in OJB? 
> 
> Thanks,
> 
> Florin
> 
> ---------------------------------------------------------------------
> 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