Bonjour,
Je tente le test suivant :
L'instance de documentType que je remove du set derrière le ExportProfil est bien supprimée au niveau JVM. Par contre le em.merge(ep3) devrait le supprimer de la base ce qui n'est pas le cas.
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa"); EntityManager em = emf.createEntityManager(); //début transaction EntityTransaction tx = em.getTransaction(); tx.begin(); ExportProfil ep3 = new ExportProfil(); ep3.setCreationDate(new Date()); ep3.setExportName("EP2"); ep3.setLanguage("FR"); ExportProcessType ept3 = new ExportProcessType(); ept3.setLanguage("fr"); ept3.setProcessTypeDN("ProcessTypeDN-EP2"); ept3.setProcessType("ProcessType-EP2"); ep3.addProcessType(ept3); ExportDocumentType edt3 = new ExportDocumentType(); edt3.setLanguage("fr"); edt3.setDocumentType("DocumentType-EP2"); edt3.setDocumentTypeDn("DocumentTypeDN-EP2"); ep3.addDocumentType(edt3); ExportDocumentField edf3 = new ExportDocumentField(); edf3.setLanguage("fr"); edf3.setDocumentFieldDN("DocFieldDN1ForDocumentType-EP2"); edf3.setDocumentField("DocField1ForDocumentType-EP2"); edt3.addDocumentField(edf3); edf3 = new ExportDocumentField(); edf3.setLanguage("fr"); edf3.setDocumentFieldDN("DocFieldDN2ForDocumentType-EP2"); edf3.setDocumentField("DocField2ForDocumentType-EP2"); edt3.addDocumentField(edf3); em.persist(ep3); //fin transaction tx.commit(); //fin EntityManager em.close(); //fin EntityMangerFactory //emf = Persistence.createEntityManagerFactory("jpa"); em = emf.createEntityManager(); //début transaction tx = em.getTransaction(); tx.begin(); Set<ExportDocumentType> exportDocumentTypes3 = ep3.getDocumentTypes(); for (ExportDocumentType documentType : exportDocumentTypes3) { int i = 1; if (i==1) { LOG.info("DOCUMENT TYPE WHICH SHOULD BE REMOVED : " + documentType); ep3.remove(documentType); i++; } /* for (ExportDocumentField documentField : documentType.getDocumentFields()) { documentField.setDocumentFieldDN(documentField.getDocumentFieldDN() + "pouet"); } */ } em.merge(ep3); tx.commit(); //fin EntityManager em.close(); //fin EntityMangerFactory emf.close();
Ca doit être tout con mais je trouve pas...
J'ai attaché les sources des objets du modèle au cas ou.
A+,
Blured.





Répondre avec citation








Partager