Saturday, 27 December 2014

Grails : Rollback

/*
 *  @author Vamsi Krishna Grandhi
 *  if you want to insert morethan one table. any table insertion failed because of errors the remaining  *  tables data can be  rollback. for that purpose the following code useful.
 *
 */

// Add data Customer & PurchaseGoods domains
com.gb.vamsi.customer.Customer.withTransaction{
if(!(new Customer(name:'Vamsi').save() && new PurchaseGoods(name:'Fruits').save())) it.setRollbackOnly()
}

No comments:

Post a Comment