-->
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: Batch insert Example , Help !
PostPosted: Mon Aug 17, 2009 2:38 am 
Newbie

Joined: Tue Aug 11, 2009 8:14 am
Posts: 1
Hi !

This is my problem:

I want to use Hibernate Batch insert.

Have 3 tables :
1. Item -- Items
2. Bill_item -- Added items to a bill
3. Bill_info -- Information about the bill (Customer Name, Date, ....... etc.)

"Bill_item" can have many "Items"
"Bill_info" can have many "Bill_item"

I have Grid of values.
..........................................................................................
Customer Name : XYZ
Date : 2/4/2009

item Id name quantity item_price Total
1 A 3 12 36
4 C 5 5 25
. . . . .
. . . . .
.......................................................etc.


i want to Store above date in two tables
First two rows in "Bill_info" table and
And Item Details in "Bill_item" table

I can Insert this as a Batch insert but the Problem is
How can i Pass these values in my method.

public void addBillItem() { ---------------------------------> How can i pass the values to this method ?

for ( int i=0; i<100000; i++ ) {

Bill_item bi= new Bill_item(.....);
session.save(bi);
if ( i % 20 == 0 ) { //20, same as the JDBC batch size
//flush a batch of inserts and release memory:
session.flush();
session.clear();
}
}

}


thanks.


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.