Illegal attempt to associate a collection with two open sessions
Salut,
J ai un petit soucie lorsque j essaye de supprimer un objet dans ma base de donnée.
J'effectue le code suivant depuis mon managed bean :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
public String deleteList() {
ec.log("Begin - deleteList()");
try {
for (int i = 0; i < dataList.size(); i++) {
selectedData = dataList.get(i);
if (selectedData.getIsSelected()) {
languageService.deleteLanguage(selectedData);
this.deleteSelectedFromDataList();
ec.log("deleteList(), selectedData to delete:"
+ selectedData);
}
}
selectedData = null;
ec.log("End - deleteList()");
return GO_LIST;
} catch (RuntimeException ex) {
ec.handleError(ERROR_DELETE, ErrorLevel.WARNING, ex);
UtilGui.setJSFErrorMessage("error_delete_list", ex);
return GO_LIST;
}
} |
et hibernate me throw une exception sur cette ligne :
Code:
1 2
|
languageService.deleteLanguage(selectedData); |
Et dans mon service j ai le code suivant :
Code:
1 2 3 4 5
|
public void deleteLanguage(Language lang) {
// TODO Auto-generated method stub
languageDbDAO.delete(lang.getDbEntity());
} |
et le code de mon DAO :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
public void delete(LanguageDb persistentInstance) {
ec.log("deleting LanguageDb instance");
try {
getHibernateTemplate().delete(persistentInstance);
ec.log("delete successful");
} catch (HibernateException he) {
ec.handleError("HibernateException", ErrorLevel.ERROR, he);
} catch (DataAccessException dae) {
ec.handleError("DataAccessException", ErrorLevel.FATAL, dae);
}
} |
Et voici le log :
FATAL http-8080-Processor24 com.mtsa.ebonus.core.db.LanguageDbDAO - 2006.07.13 14:27:25.701 FATAL_SOFT_DataAccessException Error message for this error code could not be found.|
org.springframework.orm.hibernate3.HibernateSystemException: Illegal attempt to associate a collection with two open sessions; nested exception is org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
at org.hibernate.collection.AbstractPersistentCollection.setCurrentSession(AbstractPersistentCollection.java:237)
at org.hibernate.event.def.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:41)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:104)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:64)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:58)
at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:129)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:74)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:579)
at org.springframework.orm.hibernate3.HibernateTemplate$25.doInHibernate(HibernateTemplate.java:767)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:761)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:757)
at com.mtsa.ebonus.core.db.LanguageDbDAO.delete(LanguageDbDAO.java:43)
at com.mtsa.ebonus.core.business.LanguageServiceImpl.deleteLanguage(LanguageServiceImpl.java:62)
at com.mtsa.ebonus.core.gui.LanguageGui.deleteList(LanguageGui.java:250)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
at javax.faces.component.UICommand.broadcast(UICommand.java:106)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:330)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:84)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Si quelqu un vois de quoi ca peut provenir ca serait génial
d avance merci