-->
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.  [ 2 posts ] 
Author Message
 Post subject: confused by Hibernate3 batch test
PostPosted: Sun Jun 19, 2005 5:59 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
hi everyone:

Did anyone seen the Hibernate3 testcase in

Code:
hibernate-3.0.1\test\org\hibernate\test\batch
?

There is some code in it:
Code:
Transaction t = s.beginTransaction();      
      for ( int i=0; i<N; i++ ) {
         DataPoint dp = new DataPoint();
         dp.setX( new BigDecimal(i * 0.1d) );
         dp.setY( new BigDecimal( Math.cos( dp.getX().doubleValue() ) ) );
         s.save(dp);
         if ( flushInBatches && i % 20 == 0 ) {
            s.flush();
            s.clear();
         }
      }
      t.commit();
      s.close();
      
      s = openSession();
      s.setCacheMode(CacheMode.IGNORE);
      t = s.beginTransaction();
      int i = 0;
      [b][color=red]ScrollableResults sr = s.createQuery("from DataPoint dp order by dp.x asc")
            .scroll(ScrollMode.FORWARD_ONLY);[/color]   [/b]   while ( sr.next() ) {
         DataPoint dp = (DataPoint) sr.get(0);
         dp.setDescription("done!");
         if ( flushInBatches && ++i % 20 == 0 ) {
            s.flush();
            s.clear();
         }
      }
      t.commit();
      s.close();


Why it use the ScrollableResults ?
why set ScrollMode to "FORWARD_ONLY" ? Could I get better performance by doing this? Thks!

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 19, 2005 2:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
try and read the docs about batch updates.

_________________
Max
Don't forget to rate


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