This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Bulk updates vs Sql query to update bulk records in Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Bulk updates vs Sql query to update bulk records in Hibernate" Watch "Bulk updates vs Sql query to update bulk records in Hibernate" New topic
Author

Bulk updates vs Sql query to update bulk records in Hibernate

Deeps Mistry
Ranch Hand

Joined: Jan 31, 2009
Posts: 189
Hi All,

Currently to update a bulk of records , say around 2000,I first load the records in the session, iterate over it and then update it.
This is taking tremendous amount of time, say around 10-15 mins or so.

I was thinking of optimizing this part of the code.
After doing a research, i have found that we can do bulk updates in hibernate by setting the jdbc_batch_size in hibernate and then do session.flush() and session.clear().

I just want to know that in bulk updates a single query is fired for 'n' records (where n in the number assigned to jdbc_batch_size) OR a query is fired for each record?

Also, if instead of using bulk updates, if i go forward with writing a procedure or a join sql query, which approach will give me better results performance wise?


Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bulk updates vs Sql query to update bulk records in Hibernate