hibernate - GORM: lazily save -


a) try save contact item belonging datastore domain classe following:

class contacts implements serializable{      static belongsto = [datastore:datastore]      datastore datastore     string emailaddress 

class ds:

class datastore implements serializable{      static belongsto = [service:service,user:user]     static hasmany = [users:user,contacts:contacts,groups:groups]      service service     user user     user users     list<contacts> contacts 

b) @ controller level create contact ajax request:

def create() {         string key = session["key"]         datastore ds = session["ds"]         def user = springsecurityservice.currentuser         def c = new contacts(datastore:ds,emailaddress:params.contacts.email)         if (c.validate()) {             ds.addtocontacts(c).save(flush:true)             c.save() 

c) following error prevents saving

failed lazily initialize collection of role: $$$.datastore.contacts, no session or session closed. stacktrace follows: org.hibernate.lazyinitializationexception: failed lazily initialize collection of role: $$$.datastore.contacts, no session or session closed     @ $$$$.contactscontroller$$eo4iccbg.create(contactscontroller.groovy:115)     @ grails.plugin.cache.web.filter.pagefragmentcachingfilter.dofilter(pagefragmentcachingfilter.java:195)     @ grails.plugin.cache.web.filter.abstractfilter.dofilter(abstractfilter.java:63)     @ net.bull.javamelody.jspwrapper.invoke(jspwrapper.java:149)     @ net.bull.javamelody.jdbcwrapper$delegatinginvocationhandler.invoke(jdbcwrapper.java:259)     @ net.bull.javamelody.monitoringfilter.dofilter(monitoringfilter.java:202)     @ net.bull.javamelody.monitoringfilter.dofilter(monitoringfilter.java:175)     @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:895)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:918)     @ java.lang.thread.run(thread.java:680) 

a session active ... means ? idea solve issue ? thanks

after lookine while on hibernate side grailsopensessioninviewfilter, came solution resetting datastore session this:

def dsx = datastore.get(ds.id) 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -