-->
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: Transactions management
PostPosted: Wed Dec 05, 2007 4:19 am 
Beginner
Beginner

Joined: Mon Oct 22, 2007 5:44 am
Posts: 28
Hi all,

I have a project dealing with long transactions that occur in separate classes.
A transaction may start in a specfic class and end in other class.

I tried to use the complus tpc but I guess there are better solutions. I tries also to pass the transaction object but I think it's not elegant.

Can anyone detail the transactions capabilities in NHibernate?

Thanks a lot!

_________________
dyahav


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 05, 2007 7:32 pm 
Regular
Regular

Joined: Wed Aug 15, 2007 7:37 am
Posts: 73
Hi,

If you've got access to the same (open) Session throughout the code running in the transaction it should be ok - you can begin the transaction at wherever your 'root' is and commit it / cancel it once everything's finished. I don't think you need access to the transaction while you're running updates etc. You'd need to make sure you had sufficient error handling to know whether to commit or cancel when your separate classes had finished doing their thing.

HTH.

Steve


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 06, 2007 1:26 am 
Beginner
Beginner

Joined: Mon Oct 22, 2007 5:44 am
Posts: 28
Hi Steve,

You're right, but as I understand I have to pass the transaction object to the others?
When using Complus, you do not have to pass the transaction object so it's easy to use.
Do you have any suggestions?
Thanks!

_________________
dyahav


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 06, 2007 11:23 am 
Regular
Regular

Joined: Wed Aug 15, 2007 7:37 am
Posts: 73
Hi,

I don't know what complus is. Like I said, I don't think you need to pass the transaction object at all, although you do need to pass or make available the session object that the transaction was opened on. Nothing you do on the session will be made permanent until you commit the transaction, which you can do at the top level.

Steve


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 06, 2007 11:53 am 
Beginner
Beginner

Joined: Mon Oct 22, 2007 5:44 am
Posts: 28
Hi,

It was a mistake. I intended to the Session object and not the transaction.

In COM+ you don't need to pass the session object through the components and I'm looking for something similar.

Think about 3 business components that each of them executes some CRUD operations. Component A calls to component B and B to C.

If I begin a transaction in the A component, I want that B will notice that A has already opened a transaction and A will continue this transaction.

As you mentioned previously I can pass the session obejct through the components but I want to avoid this way.

Do you have any suggestions?

Thanks a lot,

_________________
dyahav


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 06, 2007 12:06 pm 
Regular
Regular

Joined: Wed Aug 15, 2007 7:37 am
Posts: 73
Well, the easiest way I guess would be to expose the session through an object that keeps track of whether you've started a transaction. How would B know otherwise whether it must commit the transaction after (say) C finished? I don't know anything about com+ I'm afraid so I don't know how that model works.

If I were you I'd have an object that gives you access to the session and can open or close a transaction that it maintains. That way B can query it to find out whether it needs to start a transaction and if so, knows it needs to close it.

There might be functions that tell you whether a transaction's opened on a session, but I don't know off the top of my head.

Steve[/code]


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.