Return to Snippet

Revision: 10498
at January 2, 2009 11:27 by callmeblessed


Initial Code
class GtestService {

    boolean transactional = true
    
    def test() throws RuntimeException{
        // testing for transactional 
        def x = new Gtest();
        x.testName = "tester";
        if(!x.save(flush:true)){            
            throw new RuntimeException("cannot save x "); 
        }else{
            println("x id : ${x.id}");
            def y = new Gtest();
            y.testName = "tester 2 - child";
            y.parentTest = x ;
            if(!y.save(flush:true)){
                throw new RuntimeException("cannot save y"); 
            }

            // save !!! 
            throw new RuntimeException("rollback both x and y");        
        }
    }
}

Initial URL
www.wysmedia.com

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

for myutil --> please look at

Initial Title
grails: playing with transaction on service (rolling back)

Initial Tags
mysql, database, groovy

Initial Language
Groovy