-->
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.  [ 4 posts ] 
Author Message
 Post subject: transaction w/service call
PostPosted: Fri Oct 22, 2004 3:30 am 
Regular
Regular

Joined: Mon Nov 03, 2003 6:10 am
Posts: 75
I have an email service that I need to run as part of a transaction.

i.e. modify object, save, send email, (if all is good) commit transaction.

If the email fails however I don't want to commit the transaction; but I also want to be sure the db transaction will commit correctly.

can you do something like:

myPojo.save()
session.flush ??
// at this point any HibernateExceptin would have happened ??
doEmail() // if email fails.. throw exception so commit does not occur.. and rollback
session.commit();



Is this correct? Or is there someother way to do this?

Thanks

Troy


Top
 Profile  
 
 Post subject: Re: transaction w/service call
PostPosted: Fri Oct 22, 2004 1:54 pm 
Regular
Regular

Joined: Mon Nov 03, 2003 6:10 am
Posts: 75
in short. Will the flush effectively allow you to verify the success of the model changes to that point.. while still allowing for a commit/rollback to follow.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 22, 2004 1:58 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
in short. Will the flush effectively allow you to verify the success of the model changes to that point.. while still allowing for a commit/rollback to follow.


yes after a flush you can continue and choose to commit or rollback.

Note that flush is automatically executed, you generally don't need to call it...

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: clarification
PostPosted: Fri Oct 22, 2004 3:16 pm 
Regular
Regular

Joined: Mon Nov 03, 2003 6:10 am
Posts: 75
anthony wrote:
yes after a flush you can continue and choose to commit or rollback.

Note that flush is automatically executed, you generally don't need to call it...


I want to manually do the flush so I can verify that the updates/deletes/inserts etc of the transaction thus far will execute correctly (similar to committing), but still allowing for a rollback of the datbase changes if the email service fails. I am not sure if I have this right in thinking the flush will 'throw' as would a commit if some constraint failed or something


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