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.  [ 9 posts ] 
Author Message
 Post subject: Batching of Inserts/Updates/Deletes
PostPosted: Thu Aug 03, 2006 11:33 pm 
Senior
Senior

Joined: Sat Sep 03, 2005 12:54 am
Posts: 139
Hi,

I had a quick look through the NH source and it looks like insert/update/delete batching is not yet supported. Are there any plans to implement this in a future release?

Cheers,

Jason


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 5:47 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
You can look at :

http://www.hibernate.org/hib_docs/v3/re ... batch.html

For current support on Batching.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 6:08 am 
Senior
Senior

Joined: Sat Sep 03, 2005 12:54 am
Posts: 139
Hi,

I did see that doc, but I thought it was for Hibernate V3...I am using NHibernate 1.0.2.

Cheers,

Jason


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 8:09 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It can't really be implemented in NHibernate because ADO.NET doesn't support it. ADO.NET 2 supports batching but not when using plain IDbCommand/IDbConnection (one has to use DataAdapters). So currently there are no plans to do it.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 05, 2006 1:11 am 
Senior
Senior

Joined: Sat Sep 03, 2005 12:54 am
Posts: 139
Hi Sergey,

Is it not possible to send a batch of SQL statements via an IDbCommand like this:

Code:
insert into Customer values(...);
insert into Customer values(...);
insert into Customer values(...);
insert into Customer values(...);


Cheers,

Jason


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 05, 2006 11:39 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
NHibernate needs to check return values (i.e. affected row counts) for safety and this concatenated command won't return the values for individual statements.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 05, 2006 6:54 pm 
Senior
Senior

Joined: Sat Sep 03, 2005 12:54 am
Posts: 139
It would be quite easy to keep track of the row count in a contatenated batch (I can only speak for SQL Server) although I guess you have other issues like identity values from newly inserted rows too. This would be possibly via TSQL but could be pretty tricky to implement generically for multiple database engines.

Batching of the deletes would certainly seem to be easier to implement as it would only be necessary to keep track of the total rows affected.

It would be great if some time could be invested in this area because performance does suffer with the multiple hits to the DB that occurs currently, especially if the DB resides on a separate box.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 09, 2006 10:55 am 
Contributor
Contributor

Joined: Sun Jun 26, 2005 5:03 am
Posts: 51
Location: London, UK
It's slightly tricker than it first appears. NHibernate uses parameters for queries to avoid SQL injection and create more efficient SQL, so we'd have to change all of the code that creates parameters to generate explicit SQL which would be rather time consuming and bug-prone.

Unless there's a way that I don't know about to get the SQL that would be emitted by an IDBCommand, I don't see this happening.

Regards

_________________
Paul Hatcher
NHibernate Team


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 09, 2006 11:03 am 
Contributor
Contributor

Joined: Sun Jun 26, 2005 5:03 am
Posts: 51
Location: London, UK
It's slightly tricker than it first appears. NHibernate uses parameters for queries to avoid SQL injection and create more efficient SQL, so we'd have to change all of the code that creates parameters to generate explicit SQL which would be rather time consuming and bug-prone.

Unless there's a way that I don't know about to get the SQL that would be emitted by an IDBCommand, I don't see this happening.

Regards

_________________
Paul Hatcher
NHibernate Team


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