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.  [ 1 post ] 
Author Message
 Post subject: Why don't transactions work the way I'm expecting ...
PostPosted: Tue Sep 29, 2009 3:37 pm 
Newbie

Joined: Mon Mar 09, 2009 3:21 pm
Posts: 5
In the code below, I do the following:

use the Get function to get an object.

I modify the object.

I then start a new transaction, insert a new object, then commit the transaction.

However, I expect that on the commit, only an insert should happen, since the update occured [i]outside[/i] of the transaction.

However, it does both an update and an insert.

Why is it not working the way I'm expecting, and how do I get it to work the intended way? Thank you


var session = kernel.Get<ISessionFactory>().OpenSession();
var websiteUnlock = session.Get<KeyCodes.Entities.Reward>((uint)30);
websiteUnlock.RewardName = websiteUnlock.RewardName + " ADDED";

session.BeginTransaction();
session.Save(
new KeyCodes.Entities.Reward
{
ConsumerType = new KeyCodes.Entities.ConsumerType { Id = 10 },
ProductLine = new KeyCodes.Entities.ProductLine { Id = 38 },
RewardName = "Fake bob reward",
RewardTag = "NOTREAL"
});
session.Transaction.Commit();
session.Dispose();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.