This is the piece of code I am wrting
_______________________________________________
public List executeNamedQuery(String queryName,Long oid){
try
{
Query query = getHibernateTemplate().getNamedQuery(getSession(),queryName);
query.setParameter(0,oid);
return query.list();
}
catch (HibernateException e)
{
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
And this is where i am calling from
______________________________________
List li=dms.executeNamedQuery("findContentObjects",identifier);
System.out.println("li.size()="+li.size());
Template temp=(Template)li.get(0);
Temp.setBizStatus("approve");
dms.create(temp);
Actually I am doing this behind create() method
____________________________________________________
public Serializable create(Object entityObj)
{
Serializable genId =getHibernateTemplate().save(entityObj);
return genId;
}
and this is the exception I am getting, can somebody please help.
_________________________________________________________________
org.springframework.orm.hibernate.HibernateSystemException: Illegal attempt to associate a collection with two open sessions; nested exception is net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
net.sf.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
at net.sf.hibernate.collection.PersistentCollection.setCurrentSession(Lnet.sf.hibernate.engine.SessionImplementor
Z(PersistentCollection.java:257)
at net.sf.hibernate.impl.WrapVisitor.processCollection(Ljava.lang.Object;Lnet.sf.hibernate.type.PersistentCollectionType
Ljava.lang.Object;(WrapVisitor.java:42)
at net.sf.hibernate.impl.AbstractVisitor.processValue(Ljava.lang.Object;Lnet.sf.hibernate.type.Type
Ljava.lang.Object;(AbstractVisitor.java:69)
at net.sf.hibernate.impl.WrapVisitor.processValues([Ljava.lang.Object;[Lnet.sf.hibernate.type.Type
V(WrapVisitor.java:93)
at net.sf.hibernate.impl.SessionImpl.doSave(Ljava.lang.Object;Lnet.sf.hibernate.engine.Key;Lnet.sf.hibernate.persister.ClassPersister;ZZLnet.sf.hibernate.engine.Cascades$CascadingAction;Ljava.lang.Object
Ljava.io.Serializable;(SessionImpl.java:931)
at net.sf.hibernate.impl.SessionImpl.doSave(Ljava.lang.Object;Ljava.io.Serializable;Lnet.sf.hibernate.persister.ClassPersister;ZLnet.sf.hibernate.engine.Cascades$CascadingAction;Ljava.lang.Object
Ljava.io.Serializable;(SessionImpl.java:868)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(Ljava.lang.Object;Lnet.sf.hibernate.engine.Cascades$CascadingAction;Ljava.lang.Object
Ljava.io.Serializable;(SessionImpl.java:790)
at net.sf.hibernate.impl.SessionImpl.save(Ljava.lang.Object
Ljava.io.Serializable;(SessionImpl.java:749)
at org.springframework.orm.hibernate.HibernateTemplate$11.doInHibernate(Lnet.sf.hibernate.Session
Ljava.lang.Object;(HibernateTemplate.java:301)
at org.springframework.orm.hibernate.HibernateTemplate.execute(Lorg.springframework.orm.hibernate.HibernateCallback
Ljava.lang.Object;(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplate.save(Ljava.lang.Object
Ljava.io.Serializable;(HibernateTemplate.java:298)
at vz.esm.edm.service.DocumentDMS.create(Ljava.lang.Object
Ljava.io.Serializable;(Unknown Source)
at vz.esm.edm.web.DocUploadServlet.doPost(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse
V(DocUploadServlet.java:148)
at javax.servlet.http.HttpServlet.service(Ljavax.servlet.http.HttpServletRequest;Ljavax.servlet.http.HttpServletResponse
V(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse
V(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run()Ljava.lang.Object;(ServletStubImpl.java:1006)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse;Lweblogic.servlet.internal.FilterChainImpl
V(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax.servlet.ServletRequest;Ljavax.servlet.ServletResponse
V(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run()Ljava.lang.Object;(WebAppServletContext.java:6718)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic.security.subject.AbstractSubject;Ljava.security.PrivilegedAction
Ljava.lang.Object;(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Lweblogic.security.acl.internal.AuthenticatedSubject;Lweblogic.security.acl.internal.AuthenticatedSubject;Ljava.security.PrivilegedAction
Ljava.lang.Object;(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(Lweblogic.servlet.internal.ServletRequestImpl;Lweblogic.servlet.internal.ServletResponseImpl
V(WebAppServletContext.java:3764)
at weblogic.servlet.internal.ServletRequestImpl.execute(Lweblogic.kernel.ExecuteThread
V(ServletRequestImpl.java:2644)
at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest
V(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:178)
at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread
V(Unknown Source)