-->
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: Question:Why cann't I batch insert data?
PostPosted: Fri Oct 22, 2004 3:30 am 
Newbie

Joined: Fri Oct 22, 2004 3:16 am
Posts: 2
Hibernate version:hibernate-2.0.3

Mapping documents:
<mapping resource="com/dascom/ssmn/entity/SsmnCancelNum.hbm.xml"/>

My hibernate.properties is :
hibernate.dialect net.sf.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
hibernate.connection.username ssuser
hibernate.connection.password sspassword
hibernate.connection.url jdbc:oracle:thin:@192.168.91.188:1521:ora9



Code between sessionFactory.openSession() and session.close():

Session session = sessionFactory.openSession() ;
if (session == null) {
throw new DBException("fail to connect db");
}

int ilong,i;
Transaction tx = null;
SsmnCancelNum scancelnum = new SsmnCancelNum();
try {
tx = session.beginTransaction();

ilong = lcancelnum.size();
for (i = 0; i < ilong; i++) {
scancelnum = (SsmnCancelNum)lcancelnum.get(i);
session.save(scancelnum);
session.flush();
}

tx.commit();
}
catch (HibernateException he) {
System.out.println(he.toString());
}
finally {
try {
session.close();
}
catch (Exception e) {
throw new DAOException("session close error! " + e.toString());
}
}



Full stack trace of any exception that occurs:
No error,it should have been saved three records,but only saved the last record.


Name and version of the database you are using:
Oracle 9i


The generated SQL (show_sql=true):
only one Insert Sql.


Why? I cann't understand!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 22, 2004 3:49 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:43 am
Posts: 35
When you perform batch insert under Oracle it is good idea to read following post:

http://forum.hibernate.org/viewtopic.php?t=935468

I've had big problem with performance in Oracle 9i but I've solved - read post.

Read also:
http://blog.hibernate.org/cgi-bin/blosx ... batch.html

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 22, 2004 3:54 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:43 am
Posts: 35
by the way in normal situation do not use flush and commit it slow down your system. It is enought to use commit (it also perform flush)
Remeber about configuration of ConnectionPool.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 22, 2004 5:42 am 
Newbie

Joined: Fri Oct 22, 2004 3:16 am
Posts: 2
Thanks szymic1,I have worked out this question,thanks for your help.


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.