-->
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.  [ 1 post ] 
Author Message
 Post subject: Difference between batch-size and setFetchSize hibernate?
PostPosted: Mon Apr 09, 2012 12:28 pm 
Newbie

Joined: Mon Apr 09, 2012 12:14 pm
Posts: 1
I have a batch job to process the data from an oracle table and insert into Mainframe Db2 table. there is lot of XML processing involved after reading the tables. I am using hibernate to query oracle table and would prefer it to load only 100 records at a time and not all 10000+ records in the table. I read through the forums and found out multilple ways to do this.

I am currently using the below approach:

SessionFactory factory = HibernateUtil.getSessionFactory();
session = factory.openSession();

session.beginTransaction();
String sql_query = "from Activity as a where a.requestType in (:reqType) and a.requestDt between :startdate and :endDate" ;
Query query = session.createQuery(sql_query);
query.setFetchSize(100);
query.setMaxResults(500);
query.setParameterList("reqType", reqMap.get(reqType));
query.setDate("startdate", startDate);
query.setDate("endDate", endDate);

I found another example where we can define batch-size attribute to the class element of the .hbm.xml file to restrict the number of records.

Can some one please let me know what is the best approach?

Thanks
PShah.


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

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.