Hi
I want to implement transaction control at the function level. What i want is something like this.
class MyService{
static transactional = false
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public def saveCountry(){ Country co = new Country(name:'mycountry') co.save() createState()
}
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public def createState(){ State state = new State(name:'state') state.save() throw new RuntimeException() } }
What i want is that createState() creates a new transaction independent of the saveCountry(),such that if createState() fails,
the country object already saved is not revoked. Though I ve given the annotations but they dont produce the desired effect. A single transaction is created here, and it is revoked when the exception is thrown.None of the object is saved.
Can anybody help