-->
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.  [ 4 posts ] 
Author Message
 Post subject: Batch processing in one transaction
PostPosted: Fri Nov 19, 2004 3:43 pm 
Newbie

Joined: Thu Sep 02, 2004 2:31 pm
Posts: 12
I am trying to run a large data load in a single transaction based on the example:
http://blog.hibernate.org/cgi-bin/blosx ... 8/27#batch

When I run the code in a single transaction (which is important to us) the size of the Session grows continously despite the calls to clear, but when I commit the transaction and start a new one in addition to calling clear (as commented out below) the memory usage pattern is consistent with what I would expect the results of the clear call to be. I took snapshots in a profiler and saw that the growth came from the SessionImpl.executions ArrayList, which is not cleared by Session.clear(). I am hoping that I have over looked some setting, because comitting the transaction periodically wouldn't be a viable solution for me.

Thanks for your help.


Hibernate version: 2.1.6

Mapping documents:

Code between sessionFactory.openSession() and session.close():
Session session = sf.openSession();
Transaction tx = session.beginTransaction();

for (int i=0; i<10000; i++)
{
Policy p = new Policy();
// Poluate a lot of data in p
session.save(p);

if (i%100 == 0)
{
session.flush();
session.clear();
// tx.commit();
// tx = session.beginTransaction();
}
}

tx.commit();
session.close();


Full stack trace of any exception that occurs:

Name and version of the database you are using: Oracle 10

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
2004-11-19 13:33:04,781 DEBUG [net.sf.hibernate.impl.SessionFactoryImpl] - instantiating session factory with properties: {
java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition,
sun.boot.library.path=D:\j2sdk1.4.2_03\jre\bin,
java.vm.version=1.4.2_03-b02,
java.vm.vendor=Sun Microsystems Inc.,
java.vendor.url=http://java.sun.com/,
path.separator=;,
java.vm.name=Java HotSpot(TM) Client VM,
file.encoding.pkg=sun.io,
user.country=US,
sun.os.patch.level=Service Pack 4,
java.vm.specification.name=Java Virtual Machine Specification,
user.dir=D:\eclipse-3.0\workspace\CyberPARDataMapping,
java.runtime.version=1.4.2_03-b02,
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment,
java.endorsed.dirs=D:\j2sdk1.4.2_03\jre\lib\endorsed,
os.arch=x86,
java.io.tmpdir=C:\DOCUME~1\CPHILL~1\LOCALS~1\Temp\,
line.separator=
,
java.vm.specification.vendor=Sun Microsystems Inc.,
user.variant=,
os.name=Windows 2000,
sun.java2d.fontpath=,
java.library.path=D:\j2sdk1.4.2_03\bin;.;C:\WINNT\system32;C:\WINNT;D:\PROGRA~1\PVCS\vm\win32\bin;D:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.1.8\bin;D:\j2sdk1.4.2_03\bin;D:\PROGRA~1\PVCS\vm\common\bin\win32;D:\PROGRA~1\FileNET\IDM;\\nash-tracker\applications\pvcs\vm\win32\bin;\\nash-tracker\applications\pvcs\vm\common\bin\win32;D:\Program Files\ibm\gsk5\lib;d:\jdk1.3.1_06\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;D:\vim\vim61;D:\jakarta-ant-1.5.1\bin;D:\cygwin\bin;%JAXB_HOME%\bin;d:\Program Files\cvsnt;d:\Program Files\Common Files\GTK\2.0\bin,
java.specification.name=Java Platform API Specification,
java.class.version=48.0,
java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory,
os.version=5.0,
user.home=C:\Documents and Settings\cphillips,
user.timezone=America/Chicago,
java.awt.printerjob=sun.awt.windows.WPrinterJob,
file.encoding=Cp1252,
java.specification.version=1.4,
user.name=cphillips,
java.class.path=D:\eclipse-3.0\workspace\CyberPARDataMapping\bin;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\commons-collections-2.1.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\commons-dbcp-1.1.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\commons-logging-1.0.3.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\commons-net-1.2.2.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\commons-pool-1.1.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\dom4j-1.4.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\ehcache-0.6.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\jta.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\log4j-1.2.8.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\odmg-3.0.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\hibernate2.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\devlib\junit-3.8.1.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\properties\dev;D:\eclipse-3.0\workspace\CyberPARDataMapping\properties\etc;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\cglib-full-2.0.1.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\ojdbc14_g.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\commons-lang-2.0.jar;D:\eclipse-3.0\workspace\CyberPARDataMapping\lib\spring.jar,
hibernate.show_sql=false,
java.vm.specification.version=1.0,
java.home=D:\j2sdk1.4.2_03\jre,
sun.arch.data.model=32,
hibernate.dialect=net.sf.hibernate.dialect.Oracle9Dialect,
user.language=en,
java.specification.vendor=Sun Microsystems Inc.,
awt.toolkit=sun.awt.windows.WToolkit,
hibernate.cglib.use_reflection_optimizer=true,
java.vm.info=mixed mode,
java.version=1.4.2_03,
java.ext.dirs=D:\j2sdk1.4.2_03\jre\lib\ext,
sun.boot.class.path=D:\j2sdk1.4.2_03\jre\lib\rt.jar;D:\j2sdk1.4.2_03\jre\lib\i18n.jar;D:\j2sdk1.4.2_03\jre\lib\sunrsasign.jar;D:\j2sdk1.4.2_03\jre\lib\jsse.jar;D:\j2sdk1.4.2_03\jre\lib\jce.jar;D:\j2sdk1.4.2_03\jre\lib\charsets.jar;D:\j2sdk1.4.2_03\jre\classes,
java.vendor=Sun Microsystems Inc.,
hibernate.jdbc.batch_size=20,
file.separator=\,
hibernate.connection.provider_class=org.springframework.orm.hibernate.LocalDataSourceConnectionProvider,
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi,
sun.io.unicode.encoding=UnicodeLittle,
sun.cpu.endian=little,
hibernate.max_fetch_depth=0,
sun.cpu.isalist=pentium i486 i386}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 21, 2004 10:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Executions are the statements Hibernate needs to execute against the database. They are cleared by executing them; you need to flush().


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 22, 2004 10:14 am 
Newbie

Joined: Thu Sep 02, 2004 2:31 pm
Posts: 12
I am doing a session.flush prior to the session.clear call. Is this what you mean?
I have been stepping through the code and it looks like references
actually get added to the executions list during the flush call.
I searched and the only place I could find anything being removed from
executions was in SessionImpl.afterTransactionCompletion(boolean).
I apologize before hand if I am reading the code wrong, but does that mean
that those references can only be cleaned up by committing the transaction?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 22, 2004 1:37 pm 
Newbie

Joined: Thu Sep 02, 2004 2:31 pm
Posts: 12
It looks like this might be addressed in 2.1.7


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