salut tout le monde,
j'essaye désespérément de faire une opération de mise a jour mais rien a faire
J'ai 2 entités: Travail 1--------1..* Action
Travail :
ma methode d'ajout d'une action
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 @Entity @Table(name = "Travail") @NamedQueries( { @NamedQuery(name = "countDemande", query = "Select count(*) from Demande"), @NamedQuery(name = "findAllDemande", query = "Select d from Demande d order by d.libelle asc") }) public class Demande implements java.io.Serializable{ ............... private Set<Action> actions = new HashSet<Action>(); ............... @OneToMany(cascade = {CascadeType.ALL},fetch=FetchType.EAGER) public Set<Action> getActions() { return actions; }
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 public String plannification(){ try{ iddemande = new Integer(getParameter(FacesContext.getCurrentInstance(), "iddemande")); if(iddemande==null){ JSFUtils.addError("errors.unknown.id", "demande"); return "error"; } setUserInfos(); demande = publicFacade.demandeFindByPrimaryKey(iddemande); Action action = new Action(); action.setCommentaire(motifplannif); action.setDateplannification(dateplannification); action.setIntervenant(user.getRessource()); action.setDatecreationaction(new Date()); action.setTypeaction(TypeAction.PLANNIFIER); demande.getActions().add(action); demande.setIntervenant(user.getRessource()); demande.setEtat(Demande.Etat.PLANIFIEE); demande.setDateplannification(dateplannification); publicFacade.updateDemande(demande); //Affichage d'un message de réussite JSFUtils.addMessage("success.saved", "la demande"); clear(); return "success"; }catch (Exception e) { // TODO: handle exception e.getCause().printStackTrace(); } return "error"; }
SessionBean:
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 public void updateDemande(Demande updateDemande) { try{ // Lecture de la demande Demande demande = (Demande) em.find(Demande.class, updateDemande .getIddemande()); // Positionnement des infos complémentaires demande.setDateder_maj(new Date()); demande.setLibelle(updateDemande.getLibelle()); demande.setDescription(updateDemande.getDescription()); demande.setCommentaire(updateDemande.getCommentaire()); demande.setUnitetravail(updateDemande.getUnitetravail()); demande.setIntervenant(updateDemande.getIntervenant()); demande.setEtat(updateDemande.getEtat()); demande.setDatefinprevue(updateDemande.getDatefinprevue()); demande.setDateplannification(updateDemande.getDateplannification()); demande.setDaterejet(updateDemande.getDaterejet()); if(updateDemande.getEtat().equals(Demande.Etat.TERMINEE)) demande.setDatefinreel(new Date()); else if(updateDemande.getEtat().equals(Demande.Etat.REJETEE)){ demande.setDaterejet(new Date()); demande.setActions(updateDemande.getActions()); } else if(updateDemande.getEtat().equals(Demande.Etat.PLANIFIEE)){ demande.setActions(updateDemande.getActions()); } //Mise à jour du demandeur demande.setDemandeur(updateDemande.getDemandeur()); }catch (Exception ex) { // TODO: handle exception ex.getCause().printStackTrace(); return; } }
lorsque je modifie un travail pour lui ajouter une action, si c'est la premiere action associé au travail ca se passe sans probleme, mais si ce travail a deja une action a ce moment la j'ai droit au message d'erreur suivant :
quelqu'un aurait une piste ?![]()








Répondre avec citation



Partager