java - More info about save in GORM -


i have simple block of code, return false

promodebit promodebit = new promodebit();             promodebit.promocode=promocode;             promodebit.userid=userid;             promodebit.countusages=countusages;             promodebit.enddate=enddate;             promodebit.startdate=startdate;             promodebit.status=1;             promodebit.calcvalue=float.parsefloat(p.getproperty("promopercent"));              if(promodebit.save(flush: true)){                  log.info "good!"             } else {                  log.info "bad!"              } 

how can more info gorm.save fail? stdrout log show nothning if turn on logsql in datasource.groovy

first ,make sure log4j configured correctly.

here http://grails.org/doc/2.3.1/guide/conf.html#logging

and ,if wan know more detail info on gorm.save fail

        promodebit promodebit = new promodebit();         promodebit.promocode=promocode;         promodebit.userid=userid;         promodebit.countusages=countusages;         promodebit.enddate=enddate;         promodebit.startdate=startdate;         promodebit.status=1;         promodebit.calcvalue=float.parsefloat(p.getproperty("promopercent")); 

then ,

if (!promodebit.save()) {    log.warn mydomainobj.errors.allerrors.join(' \n')     //each error instance of  org.springframework.validation.fielderror     } 

and , one

if (!promodebit.save()) {     promodebit.errors.each {         println     } } 

if want throw exception every domain classes, set grails.gorm.failonerror true in grails-app/conf/config.groovy

or simply

promodebit.save(failonerror:true) 

cheers!


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -