Note that there are some explanatory texts on larger screens.

plurals
  1. POPage Refresh(F5) changes the data on the screen after successful save in db in Grails app
    primarykey
    data
    text
    <p>I have developed a grails/groovy application for a legacy database which has user maintenance page to (add,edit) user information. The page is using editinplace and ajax to update the information. </p> <p>The program has been tested on local with no problem. However, on any remote server (alpha,beta,prod) when I "update" any property of user, it will save it in the database but when I refresh the page the contents "sometimes" go back the previous values. If I keep pressing refresh (F5) it will switch between old and new values without any particular trend. (wasn't able to reproduce in local)</p> <p>I thought it might be a cache issue so I set cache false on user domain </p> <pre><code>class User { static hasMany = [notes: Note] static mapping = { table 'MICR_USERS' cache false version false id generator:'sequence', column:'SEQ_ID', params:[sequence:'MICR_USR'] lineOfBusiness column:'LOB_APP_CODE' authorityProfile column:'AUTH_PRIVILEGE_LEVEL', lazy:false } ... </code></pre> <p>Another thing I thought might cause the issue is the createCriteria in list action which I set the cache false there too</p> <pre><code> def list = { def f = getUserList(session.oldSearchUserTextBox?:null) return [list:f,oldSearchKeyword:session.oldSearchUserTextBox] } private getUserList(String searchFilter){ .... def c = User.createCriteria() def results if (searchFilter) { results = c.list (max: params.max, offset: params.offset) { or { ilike ("oraAcct", "%"+ searchFilter+"%" ) ilike ("lastName", "%"+ searchFilter+"%" ) ilike ("firstName", "%"+ searchFilter+"%" ) } order("oraAcct", "asc") cache false } } else { results = c.list (max: params.max, offset: params.offset) { cache false order("oraAcct", "asc") } } [userInstanceList : results,userInstanceTotal :results.getTotalCount()] } </code></pre> <p>This is my save method </p> <pre><code> private JSON saveValidateObj(def myUser,def oldValue,def fieldname,def returnFieldName){ try { def value = myUser."$fieldname" if( myUser.validate() &amp;&amp; myUser.save(flush:true) ) { if (returnFieldName) value = value."$returnFieldName" flashMessage = getMess('user.information.update.success',[ myUser.oraAcct, oldValue, value ]) def json = ['value':value,'id':params.id,'updatedField': fieldname,'errorList':null,'errMessage':null,'okMessage':flashMessage] def j = json as JSON return j } </code></pre> <p>.....</p> <p>It seems that hibernated keeps different version of the data and by refreshing the page randomly one of those versions will be displayed. However, the latest values are dominant and appear more frequently but still seeing the old values appearing on the screen is devastating.</p> <p>These are the steps I did and didn't help 1- turned off the caching (checked the hibernate statistics to make sure its off) cache.use_second_level_cache=false cache.use_query_cache=false</p> <p>2- tried it in different browsers</p> <p>3- cleaned the browser cache and deleted cookies</p> <p>I am also suspicious on websphere which is my production server and my local is apache but really dont know why its reacting this way</p> <p>Grails/hibernate 1.1</p> <p>I still have this issue and could not think of anything else. I appreciate, if anyone can provide me any hint</p> <p><strong>New Findings</strong></p> <p>If I use <code>select u.id, u.sysAcct, u.firstName, u.lastName, u.mailAddress, u.phoneExt from User u... </code> the problem will be solved. but if I use <code>select u from User u,...</code> the problem will happen again. For some reason if I return the User object this issue happens. The getUserListHSQLStatic and getUserListHSQL are basically same except one is returning the object and one is returning fields. the values from the static one will never change by pressing F5 but the object (User) one will change. </p> <pre><code> private getUserListHSQLStatic(params){ def filter = params.filter def newlist def count def query = """ select u.id, u.sysAcct, u.firstName, u.lastName, u.mailAddress, u.phoneExt ,lob.name,auth.name from User u, AuthorityProfile auth, LineOfBusiness lob where u.authorityProfile = auth.id and u.lineOfBusiness = lob.id and u.sysAcct not like '%DUMMY%' """ if (filter){ query +=""" and (u.sysAcct like :filter or u.sysAcct like :lfilter or u.firstName like :filter or u.firstName like :lfilter or u.lastName like :filter or u.lastName like :lfilter ) order by u.sysAcct asc """ def filterMap = [filter:"%${filter.toUpperCase()}%",lfilter:"%${filter.toLowerCase()}%"] newlist = User.executeQuery(query,filterMap, [ max:params?.max?.toInteger()?:10, offset:params?.offset?.toInteger()?:0] ) count = User.executeQuery(query,filterMap).size() } else { query += " order by u.sysAcct asc " newlist = User.executeQuery(query,[max:params?.max?.toInteger()?:10, offset:params?.offset?.toInteger()?:0]) count = User.executeQuery(query).size() } [userInstanceList:newlist,userInstanceTotal:count] } private getUserListHSQL(params){ def mysession = sessionFactory.currentSession if (params.reset=="true"){ println "clear session" mysession.clear() } def filter = params.filter def newlist def count def query = """ select u from User u, AuthorityProfile auth, LineOfBusiness lob where u.authorityProfile = auth.id and u.lineOfBusiness = lob.id and u.sysAcct not like '%DUMMY%' """ if (filter){ query +=""" and (u.sysAcct like :filter or u.sysAcct like :lfilter or u.firstName like :filter or u.firstName like :lfilter or u.lastName like :filter or u.lastName like :lfilter ) order by u.sysAcct asc """ def filterMap = [filter:"%${filter.toUpperCase()}%",lfilter:"%${filter.toLowerCase()}%"] newlist = User.executeQuery(query,filterMap, [ max:params?.max?.toInteger()?:10, offset:params?.offset?.toInteger()?:0] ) count = User.executeQuery(query,filterMap).size() } else { query += " order by u.sysAcct asc " newlist = User.executeQuery(query,[max:params?.max?.toInteger()?:10, offset:params?.offset?.toInteger()?:0]) count = User.executeQuery(query).size() } [userInstanceList:newlist,userInstanceTotal:count] } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload