[CMP] Problème avec l'extraction de la collection des fk.
Bonjour,
Je veux extraire une collection représentant des clés étrangères d'une CMR (1:N), mais à chaque fois ça me genere une exception bien que , dans le sens inverse, quand j'extrais la clé étrangère du coté de la cardinalité N, ça marche bien.
L'erreur est la suivante
Code:
"A CMR collection may only be used within the transction in which it was created"
.
Le context est le suivant; une commande a plusieurs lignes de commande
Mes tables sont :
Code:
1 2
| commande(commande_id, date, .....)
ligne(ligne_id, quantite,......, commande_id) |
Je represente ça par deux EJBs : CommandeBean et LigneBean.
et je teste dans une servlet, en débogant ça donne :
Code:
1 2 3 4
| //Obtention de l'object comm via son context jndi, j'utilise l'interface locale
CommandeLocal comm = CommandLocalHome.findByPrimaryKey(new Integer(2)); //Ca marche
System.out.println(comm.getDate()); //ca marche bien
Collection coll = comm.getLignes(); //Ici ca plante en me disant "A CMR collection may only be used within the transction in which it was created" |
En faisant ça du coté de la cardinalité N, ca marche bien
Code:
1 2 3 4
| //obtention de l'objet ligne_commande via son context jndi, j'utilise l'interafce locale
ligneLocal ligne_commande = LigneLocalHome.findByPrimaryKey(new Integer(1)); //ca marche
System.out.println(ligne_commande.getQuantite()); //ca marche
System.out.println((ligne_commande.getCommande()).getcommande_id);//ca //marche bien. |
Merci d'avance pour votre aide.