aop transactions

9 views
Skip to first unread message

Chris Blackwell

unread,
May 21, 2013, 9:36:39 AM5/21/13
to coldspring-users
Is it possible to use aop transactions and manually send a rollback command?

for example

/**
* @transactional true
*/
function updateUser(user, data) {
  user.popluate(data);
  if(!user.validate()) {
    // rollback ??
  }
  else {
    // continue..
  }
}

Is this possible with aop, or do i need to manually code the transactions inside the method?

Cheers, Chris

Brian Kotek

unread,
May 21, 2013, 9:41:02 AM5/21/13
to coldspri...@googlegroups.com
Fairly sure that if you throw an exception, the wrapping transaction should roll back automatically.


--
You received this message because you are subscribed to the Google Groups "ColdSpring-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldspring-use...@googlegroups.com.
To post to this group, send email to coldspri...@googlegroups.com.
Visit this group at http://groups.google.com/group/coldspring-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Blackwell

unread,
May 21, 2013, 9:45:43 AM5/21/13
to coldspring-users
What if i wanted to return something to the caller, like the validation result ?
too much ?

Brian Kotek

unread,
May 21, 2013, 9:56:29 AM5/21/13
to coldspri...@googlegroups.com
Ah I see...in that case, what about using TransactionRollback()? I *believe* that should roll back whatever the currently active transaction is. 

Chris Blackwell

unread,
May 21, 2013, 10:52:36 AM5/21/13
to coldspring-users
for some reason i thought coldspring was manipulating the hibernate transaction directly, but looks like its just wrapping the proceed() in a <cftransaction> block if its not already in a transaction.  So calling transactionRollback() works ok as far as i can tell.

As to whether its desirable to mix transactions applied via annotations with explicitly coded rollback's i'm unsure..


Reply all
Reply to author
Forward
0 new messages