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.  [ 2 posts ] 
Author Message
 Post subject: ISession.Save() transaction enlistment
PostPosted: Sat Nov 01, 2008 3:15 pm 
Newbie

Joined: Sat Nov 01, 2008 3:00 pm
Posts: 1
Hello! I'm a new NHibernate user, and I've been struggling with an issue for a couple of days, however I think I figured out what the problem is - I just need to confirm that this is, indeed, how NHibernate is supposed to work.

In my code, I have a mixture of using ISession.Save() as well as custom SQL queries (I've also used Named Queries, but the result was the same).

Code:
this.dataAccessManager.Save(o);
this.dataAccessManager.CreateUpdateQuery("UPDATE " + tableName + " SET createdBy=:createdBy WHERE id=:uid", parameters);


All of these are wrapped in the same transaction, however, the ordering of these statements is very important. The object obviously must be saved first before the update statement is executed.

Looking at the logs, it seems as though whenever IQuery.ExecuteUpdate() is called, the command is enlisted in the transaction immediately, whereas the ISession.Save() commands aren't enlisted in the transaction until ISession.Transaction.Commit() is invoked.

I suppose that this behaviour makes sense, but is there a way to have the ISession.Save() method enlist the database command into the active transaction immediately, rather than waiting for the Commit() method to be called?

Please let me know if you need more information - and thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 01, 2008 7:30 pm 
Newbie

Joined: Tue Oct 28, 2008 3:12 pm
Posts: 6
No, Commit() and Flush() only could flush data to db, made by Save, Update and other methods.
Why it is so important?

_________________
Could u tell me, when I have mistakes in English plz? :)


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