Posted By

callmeblessed on 01/02/09


Tagged

mysql database groovy grails transaction


Versions (?)

grails: playing with transaction on service (rolling back)


 / Published in: Groovy
 

URL: www.wysmedia.com

how to rollback data on grails' service ....

for myutil --> please look at

  1. class GtestService {
  2.  
  3. boolean transactional = true
  4.  
  5. // testing for transactional
  6. def x = new Gtest();
  7. x.testName = "tester";
  8. if(!x.save(flush:true)){
  9. throw new RuntimeException("cannot save x ");
  10. }else{
  11. println("x id : ${x.id}");
  12. def y = new Gtest();
  13. y.testName = "tester 2 - child";
  14. y.parentTest = x ;
  15. if(!y.save(flush:true)){
  16. throw new RuntimeException("cannot save y");
  17. }
  18.  
  19. // save !!!
  20. throw new RuntimeException("rollback both x and y");
  21. }
  22. }
  23. }

Report this snippet  

You need to login to post a comment.