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:

  1. perform check before point @ exception raised, , don't execute offending code under conditions know throw exception
  2. 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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -