Bonjour,
je travaille avec hibernate 3.1, eclipse 3.1, mysql5 et java5.
J'ai une méthode de suppression en base, qui doit supprimer un objet et toutes ses dépendances, c'est à dire une identite, et puis son adresse, son infraction, l'adresse de l'infraction :
Hibernate me renvoie l'erreur suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public static void supprimerIdentite(Integer ididentite) { _RootDAO.initialize(); Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); tx.begin(); try { InfractionDAO ilsDAO = new InfractionDAO(); AdresseDAO adDAO = new AdresseDAO(); //adresse de domicile session.createQuery("delete from Adresse where IDENTITE_ID_IDENTITE = :idIdentite ").setInteger("idIdentite", ididentite).executeUpdate(); //infractions (connexes) Infraction inf = (Infraction)session.createQuery("from Infraction where IDENTITE_ID_IDENTITE = :idIdentite"). setInteger("idIdentite",ididentite ).uniqueResult(); if (inf != null) { //adresse infraction session.createQuery("delete from Adresse where INFRACTION_ID_ILS = :idInf ").setInteger("idInf", inf.getIdIls()).executeUpdate(); ilsDAO.delete(inf); } //identite (alias et surnom) IdentiteDAO idDAO = new IdentiteDAO(); idDAO.delete(ididentite); tx.commit(); session.close(); } catch (HibernateException e) { tx.rollback(); session.close(); e.printStackTrace(); } catch (Exception e) { tx.rollback(); session.close(); e.printStackTrace(); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 Hibernate: delete from adresse where INFRACTION_ID_ILS=? org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions at org.hibernate.collection.AbstractPersistentCollection.setCurrentSession(AbstractPersistentCollection.java:410) at org.hibernate.event.def.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:40) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61) at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55) at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123) at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:72) at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:764) at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:743) at com.osiris.hibernate.beans.base._BaseRootDAO.delete(_BaseRootDAO.java:761) at com.osiris.hibernate.beans.base._BaseRootDAO$5.run(_BaseRootDAO.java:749) at com.osiris.hibernate.beans.base._BaseRootDAO.run(_BaseRootDAO.java:788) at com.osiris.hibernate.beans.base._BaseRootDAO.delete(_BaseRootDAO.java:746) at com.osiris.hibernate.beans.base.BaseInfractionDAO.delete(BaseInfractionDAO.java:194) at com.osiris.services.specifique.SupprimerService.supprimerIdentite(SupprimerService.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at flashgateway.adapter.java.JavaAdapter.invokeFunction(JavaAdapter.java:55) at flashgateway.filter.AdapterFilter.invoke(AdapterFilter.java:117) at flashgateway.filter.MessageSecurityFilter.invoke(MessageSecurityFilter.java:144) at flashgateway.filter.ServiceNameFilter.invoke(ServiceNameFilter.java:101) at flashgateway.filter.EnvelopeFilter.invoke(EnvelopeFilter.java:102) at flashgateway.filter.SessionFilter.invoke(SessionFilter.java:28) at flashgateway.filter.LicenseFilter.invoke(LicenseFilter.java:57) at flashgateway.filter.ErrorFilter.invoke(ErrorFilter.java:39) at flashgateway.filter.LogFilter.invoke(LogFilter.java:46) at flashgateway.filter.BatchProcessFilter.invoke(BatchProcessFilter.java:63) at flashgateway.filter.PacketSecurityFilter.invoke(PacketSecurityFilter.java:68) at flashgateway.filter.DebugFilter.invoke(DebugFilter.java:38) at flashgateway.filter.SerializationFilter.invoke(SerializationFilter.java:89) at flashgateway.Gateway.invoke(Gateway.java:217) at flashgateway.controller.GatewayServlet.service(GatewayServlet.java:69) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 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(Unknown Source)
N'est-il pas possible d'avoir plusieurs opérations dans la même transaction ??? Oua lors, dois-je merger certains objets entre les requêtes ??
Partager