-->
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.  [ 3 posts ] 
Author Message
 Post subject: MySQL bulk insert
PostPosted: Tue Jan 27, 2009 9:32 pm 
Newbie

Joined: Fri Dec 26, 2008 1:13 am
Posts: 8
Hi,

I am using hibernate 3 with MySQL and was wondering how I can do a bulk insert from a ArrayList of hibernate objects. I googled and got many hits, but could not find a solution to my case. I want to generate a query like:

INSERT INTO sometable (col1, col2, col3) VALUES (1,2,3),(4,5,6),(7,8,9)

But everything I try with hibernate creates three SQL queries like this:

INSERT INTO sometable (col1, col2, col3) VALUES (1,2,3)
INSERT INTO sometable (col1, col2, col3) VALUES (4,5,6)
INSERT INTO sometable (col1, col2, col3) VALUES (7,8,9)

Anybodu knows how I can fix this?

Thank you!
Andrej


Top
 Profile  
 
 Post subject: Re
PostPosted: Wed Jan 28, 2009 4:59 am 
Beginner
Beginner

Joined: Wed Nov 26, 2008 1:02 am
Posts: 22
hi,
that is not possible with Hibernate,Hibernate will generate a insert query when an object saved,

_________________
if it solves,rate me


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2009 5:23 am 
Newbie

Joined: Fri Dec 26, 2008 1:13 am
Posts: 8
That is very inefficient. Of course I can create a bulk-insert with a StringWriter, but when the database object changes, the compiler does not warn me about that. Awkward....


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