bonjour,
j'ai créé une procédure, qui lors d'une rectification du montant d'une opération, crée 2 nouvelles opérations avec toutes les informations identiques à celle à rectifier, sauf que pour une,le montant =-montant existant, et pour l'autre montant=nouveau montant,
voilà l'exception
Array index out of range: 1
voilà le code: (je vous ai expliqué ce qu'il faut,mais dans ce code j'ai voulu ,comme essai, de faire l'insertion d'une seule opération avec le nouveau montant)
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
public String recherche() {
        EntityManager em = getEntityManager();
        try {
            utx.begin();
           List<Operation> oper=em.createQuery("select o.npch,o.montant from Operation as o where (o.npch=:n)")
                   .setParameter("n",operation.getNpch()).getResultList();
           if(!oper.isEmpty());
           {       
           operation.setCodActiv(oper.get(1).getCodActiv());
           operation.setCodCaisse(oper.get(1).getCodCaisse());
           operation.setCodTransac(oper.get(1).getCodTransac());
           operation.setDateOp(oper.get(1).getDateOp());
           operation.setDateVersm(oper.get(1).getDateVersm());
           operation.setImpAnal(oper.get(1).getImpAnal());
           operation.setImpBudi(oper.get(1).getImpBudi());
           operation.setMatriculeAgent(oper.get(1).getMatriculeAgent());
           operation.setMoisPaie(oper.get(1).getMoisPaie());
           operation.setMontantht(oper.get(1).getMontantht());
           operation.setNpch(oper.get(1).getNpch());
           operation.setNumMandat(oper.get(1).getNumMandat());
           //***montant soit =(-op.getMontant)soit = nouveau montant
           operation.setMontant(operation.getMontant());
              em.persist(operation);      
             utx.commit();
           }
             return listSetup();
           } catch (Exception ex) {
            try {                
                    ensureAddErrorMessage(ex, "A persistence error occurred.");
 
                utx.rollback();
            } catch (Exception e) {
               e.printStackTrace();
                ensureAddErrorMessage(e, "An error occurred attempting to roll back the transaction.");
            }
            return null;
        } finally {
            em.close();
        }
        }
j'espère que quelqu'un pourra m'aider,(je n'ai pas pu m'ensortir, j'ai essayé plusieurs formes,(dans certaines j'ai eu des exceptions qui m'affichent "java.util.object")

merci d'avance