-->
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.  [ 6 posts ] 
Author Message
 Post subject: Is it possible to execute Batch Statements in a Single Trip?
PostPosted: Sun Sep 30, 2007 7:02 pm 
Newbie

Joined: Wed Sep 05, 2007 1:25 am
Posts: 10
Hi
Again new to NHibernate and wondering if Could do the following in 1 trip to the db

1 Select from Table A
1 Update Table A etc....
1 Select or insert 0r Delete Table B


What I am asking here is without using Stored Procedures can I do 3 different statement in 01 Trip to the DB?

Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 01, 2007 4:21 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
You can do multiple queries if you use the trunk version at the moment using the multi query functionality Ayende implemented.

As for batching inserts and updates, they normally occur together during a flush.

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 01, 2007 4:30 am 
Newbie

Joined: Wed Sep 05, 2007 1:25 am
Posts: 10
Thanks for your reply.

I knew i could do multiple queries but I was not sure I could do

A Select
Update
and Select again

the above 3 sql statement if you like in 1 db trip.
You say I can .Is that Correct?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 01, 2007 1:01 pm 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Not exactly. Modification of the state of persistent objects (Updates, inserts, deletes) are performed when a flush occurs. The timing of a flush depends on your settings, and could happen when you do a query or when you commit your transaction.

Unless you've changed the default flush settings normally if you execute a query any in-memory changes will be automatically flushed to the database to ensure the result set you get is accurate. As a result of this behavior you are effectively getting what you asked for.

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 01, 2007 1:04 pm 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Ah, missed the 1 DB trip part.

No. You can't have it. Nyaaaa! :) But seriously, I think each of the inserts, updates, etc are executed in their own db roundtrip. Sorry.

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 01, 2007 1:47 pm 
Beginner
Beginner

Joined: Mon Jul 30, 2007 4:58 pm
Posts: 21
write a stored procedure and call it via nhibernate.


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