-->
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.  [ 5 posts ] 
Author Message
 Post subject: performance issue with hibernate return java.util.list
PostPosted: Tue Jun 19, 2007 1:27 am 
Newbie

Joined: Tue Oct 17, 2006 5:18 am
Posts: 9
I use hibernate 3.2 with the following code

List listobj = sess.createQuery("from TransactionTx g left join fetch g.user left join fetch g.user1 left join fetch g.appparamid where (g.user = :userid or g.user1 = :userid)").setEntity("userid", user).list();

with hbm file as a follow

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.arkalogic.parkalogic.ejb.pojo">
<class name="com.TransactionTx" table="transaction_tx">
<id name="id" type="string"/>
<many-to-one name="user" fetch="join" column="user_id_in" class="com.User" />
<many-to-one name="user1" fetch="join" column="user_id_out" class="com.User" /><property name="entrymanual" column="entry_manual" type="boolean"/>
<many-to-one name="appparamid" fetch="join" column="app_param_id" class="com.AppParam"/>
<property name="photo1in" column="photo1" type="binary"/>
<property name="photo2in" column ="photo2" type="binary"/>
<property name="photo1out" column="photo1out" type="binary"/>
<property name="photo2out" column="photo2out" type="binary"/>
<property name="archive" type="boolean"/>
</class>
</hibernate-mapping>


In TransactionTx table there's about 119.000 record with images in it
Now, when I fill out listobj with all record in TransactionTx table, the process would take minimum 7 minute to finish and the memory usage will increase into 70-90% from it capacity and the computer will just slowing down because lack of memory. My pc is using 1 giga byte of ram with 3 giga hertz of pentium 4.
Is hibernate slow if dealing with large amount of data and record?
How can I speed this up, or anyone can share with me tip and trick about dealing with large amount of record and data with hibernate

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2007 2:13 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

I don't know exactly what you want. I think you don'r want all record at same time. So you can use hibernate fetching size to get selected number of records at a time.

query.setMaxResults(10);
query.setFirstResult(1);

you can set FirstResult dynamicallly

Amila
(Don't forget to rate if helps)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2007 6:50 am 
Newbie

Joined: Tue Oct 17, 2006 5:18 am
Posts: 9
amila733 wrote:
Hi

query.setMaxResults(10);
query.setFirstResult(1);

(Don't forget to rate if helps)


How come when I use this I still get all record in the table instead getting 10 record only


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2007 7:22 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

Query listobj = sess.createQuery("from TransactionTx g left join fetch g.user left join fetch g.user1 left join fetch g.appparamid where (g.user = :userid or g.user1 = :userid)");
listobj=listobj.setMaxResults(10);
listobj=listobj.setFirstResult(1);
listobj.setEntity("userid", user);
List list=listobj.list();

Amila

(Don't forget to rate if helps);


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 6:50 am 
Newbie

Joined: Sat Jun 17, 2006 5:28 am
Posts: 8
Location: Egypt
Quote:
How come when I use this I still get all record in the table instead getting 10 record only?


As you will not display the the full table records in only one page you will do some pagination and this is the idea you will fetch the number of records matching the page number you are in.
Imagine you have 500 records and you will display them 10 per page so you will have 50 pages.

so by following the below methodology

List fetchPageData(int startRow, int pageRecordsSize) {
.setMaxResults(pageRecordsSize); // 10
.setFirstResult(startRow); // 1
}

fetchPageData(1, 10);

it will fetch the first 10 records if you make scrolling to third page
make the following call

fetchPageData(20, 10);

hope it helps


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.