-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Performance Question
PostPosted: Wed Mar 31, 2004 1:48 pm 
Newbie

Joined: Tue Nov 11, 2003 4:45 pm
Posts: 2
Hi, everybody, i have a question about performance loading objects.
How method is better??? Load a perssisted object by query or by load method?????.
Examples:
// session is an instance of Session class.

Query query = session.getNamedQuery("subsidios.practicas.x.pk");
query.setLong(0, dto.getNumero().longValue());
java.util.Iterator it = query.iterate();

// Code from named query
<query name="subsidios.practica.x.pk"><![CDATA[
from Practica as p
where p.numero = ?
]]>
</query>

The second choice:
// dto.getNumero() returns the long id
Practica p = (Practica) session.load(Practica.class, dto.getNumero());

Thanks for all suggestions!!!!.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 31, 2004 3:26 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
session.load() is usually recommended if you know the uid assigned to the object - this because it won't it the database if the object is already loaded by the current session (either directly or because it is a member of an already loaded collection)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 01, 2004 3:54 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
unless you cache the query, use load.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.