grails - Data not persisted after return from service -
let me preface saying code working yesterday. rolled commits time when working.
the thing different migration ran today remove columns tables. can't see how affect
i'm doing google oauth authentication , in callback url google doing lot of saves/updates/etc.. controller calls single service everything. if query data while @ breakpoint return statement is, can see data. there no exceptions, validation errors, or lead me believe wrong. ideas?
class mycontroller { def myservice def callback() { myservice.update() //at point when run x.get(1) returning null redirect uri: "..." } } @transactional class myservice { def update() { ... //if break @ return statement can run x.get(1) , returns return somedata; } }
edit: i've found cause, don't understand how happening. i'm calling userdetailsservice.loaduserbyusername
. method throwing nostackusernamenotfoundexception
. i'm catching exception in code, causing transaction roll regardless.
any exception thrown during transaction, if catch , deal it, cause transaction roll back.
to around have couple of options:
- perform check before point @ exception raised, , don't execute offending code under conditions know throw exception
- do transaction handling -
in service, set
static transactional = false
then declare own transaction block:
mydomain.withtransaction { tx -> try { userdetailsservice.loaduserbyusername(...) } catch (nostackusernamenotfoundexception e) { log.warn("can't load user...") } //stuff try persist here //be written database //despite nostackusernamenotfoundexception //being thrown & caught }
Comments
Post a Comment