spring - active objects java.lang.RuntimeException: Failed to lazily initialize a collection - no session or session was closed -


i trying implement @onetomany relationship using active objects

my entities , service classes below

package jp.co.kodnet.confluence.plugins.bookdirectory.rest; 

entity

import java.util.date; import net.java.ao.onetomany; import net.java.ao.preload;  /**  *  * @author kod  */ @preload public interface  crossreference extends entity {         void setbookkey(string bookkey);             string getbookkey();      void setbookname(string bookname);             string getbookname();      void setspacekey(string spacekey);             string getspacekey();      void setspacename(string spacename);             string getspacename();      void setpageid(long pageid);             long getpageid();      void setlastmodifieddate(date lastmodifieddate);             date getlastmodifieddate();      void setcodenumcount(integer codenumcount);             integer getcodenumcount();      @onetomany     codeelements[] getcodeelements();      @onetomany     spanelements[] getspanelements();         } 

entity
import net.java.ao.preload;

/**  *  * @author kod  */ @preload public interface codeelements extends entity {      public string getdetailtype();     public void setdetailtype(string detailtype);      public string getcharttitle();         public void setcharttitle(string charttitle);      public string getcharttag();         public void setcharttag(string charttag);      public crossreference getcrossreference();             public void setcrossreference(crossreference cs);        } 

entity
package jp.co.kodnet.confluence.plugins.bookdirectory.rest;

import net.java.ao.preload;  /**  *  * @author kod  */ @preload public interface spanelements extends entity {      public string getbookmarkname();         public void setbookmarkname(string bookmarkname);      public string getbookmarkstring();         public void setbookmarkstring(string bookmarkstring);      public crossreference getcrossreference();             public void setcrossreference(crossreference cs);             } 

service impl
public class activityserviceimpl implements activityservice { private final activeobjects ao; private crossreference crossreference;

    public activityserviceimpl(activeobjects ao)     {         this.ao = checknotnull(ao);     }      @override     public void add(string bookkey, string bookname, string spacekey,                             string spacename, long pageid, date lastdate) {         try {             final crossreference cs = ao.create(crossreference.class);             cs.setbookkey(bookkey);             cs.setbookname(bookname);             cs.setspacekey(spacekey);             cs.setspacename(spacename);             cs.setpageid(pageid);             cs.setlastmodifieddate(lastdate);             cs.save();         }         catch (exception e)         {             throw new runtimeexception(e);         }     }          @override     public void add(string bookkey, string bookname, string spacekey,                             string spacename, long pageid, date lastdate,                             integer codenumcount,                             string detailtype,                             string charttitle,                             string charttag) {         try {             final crossreference cs = ao.create(crossreference.class);             cs.setbookkey(bookkey);             cs.setbookname(bookname);             cs.setspacekey(spacekey);             cs.setspacename(spacename);             cs.setpageid(pageid);             cs.setlastmodifieddate(lastdate);             final codeelements codeelement = ao.create(codeelements.class);             codeelement.setdetailtype(detailtype);             codeelement.setcharttitle(charttitle);             codeelement.setcharttag(charttag);             codeelement.setcrossreference(cs);             codeelement.save();         }         catch (exception e)         {             throw new runtimeexception(e);         }     }      @override     public void add(string bookkey, string bookname, string spacekey,                             string spacename, long pageid, date lastdate,                             integer codenumcount,                             string bookmarkname,                             string bookmarkstring) {         try {             final crossreference cs = ao.create(crossreference.class);             cs.setbookkey(bookkey);             cs.setbookname(bookname);             cs.setspacekey(spacekey);             cs.setspacename(spacename);             cs.setpageid(pageid);             cs.setlastmodifieddate(lastdate);             final spanelements spanelement = ao.create(spanelements.class);             spanelement.setbookmarkname(bookmarkname);             spanelement.setbookmarkstring(bookmarkstring);             spanelement.setcrossreference(cs);             spanelement.save();         }         catch (exception e)         {             throw new runtimeexception(e);         }     }  getting following error, ideas why   [info] [talledlocalcontainer] java.lang.runtimeexception: failed lazily initialize collection - no session or session closed [info] [talledlocalcontainer]   @ com.atlassian.event.internal.singleparametermethodlistenerinvoker.invoke(singleparametermethodlistenerinvoker.java:54) [info] [talledlocalcontainer]   @ com.atlassian.event.internal.asynchronousableeventdispatcher$1$1.run(asynchronousableeventdispatcher.java:48) [info] [talledlocalcontainer]   @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)`enter code here` [info] [talledlocalcontainer]   @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) [info] [talledlocalcontainer]   @ java.lang.thread.run(thread.java:745) [info] [talledlocalcontainer] caused by: net.sf.hibernate.lazyinitializationexception: failed lazily initialize collection - no session or session closed [info] [talledlocalcontainer]   @ net.sf.hibernate.collection.persistentcollection.initialize(persistentcollection.java:209) [info] [talledlocalcontainer]   @ net.sf.hibernate.collection.persistentcollection.read(persistentcollection.java:71) [info] [talledlocalcontainer]   @ net.sf.hibernate.collection.bag.isempty(bag.java:240) [info] [talledlocalcontainer]   @ com.atlassian.confluence.core.contententityobject.getbodycontent(contententityobject.java:192) [info] [talledlocalcontainer]   @ com.atlassian.confluence.core.contententityobject.getbodycontent(contententityobject.java:210) [info] [talledlocalcontainer]   @ com.atlassian.confluence.core.contententityobject.getbodyasstring(contententityobject.java:251) [info] [talledlocalcontainer]   @ jp.co.kodnet.confluence.plugins.bookdirectory.listeners.registercrossreferencelistener.cr_converthtmldocument(registercrossreferencelistener.java:256) [info] [talledlocalcontainer]   @ jp.co.kodnet.confluence.plugins.bookdirectory.listeners.registercrossreferencelistener.crossreferenceregitered(registercrossreferencelistener.java:104) [info] [talledlocalcontainer]   @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) [info] [talledlocalcontainer]   @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) [info] [talledlocalcontainer]   @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) [info] [talledlocalcontainer]   @ java.lang.reflect.method.invoke(method.java:606) [info] [talledlocalcontainer]   @ com.atlassian.event.internal.singleparametermethodlistenerinvoker.invoke(singleparametermethodlistenerinvoker.java:36) [info] [talledlocalcontainer]   ... 4 more 


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -