Hi!
I have migrated JDO to JPA (Due to the problem of persistence), but
it now  never updates the object "Torneo", when I add an element to
the  collection.
The code:
        public void agregarEquipoConTorneo(Torneo unTorneo, Equipo
unEquipo)
{
           EntityTransaction utx = em.getTransaction();
          //em is private final EntityManager em =
EMF.get().createEntityManager();
          try{
                 utx.begin();
                 Torneo tor= em.find(Torneo.class, unTorneo.getId());
                 //retrieve the object to update
                 tor.agregarEquipo(unEquipo);
                 //add un Equipo to collection
                 em.persist(tor);
                  em.refresh(tor); // refresh here
                  utx.commit();
                System.out.println("persistioTorneoConEquipo");
        }
                 finally {
                        //pm.close();
                        if (utx.isActive()) {
                                //tx.rollback();
                        }
                        em.close();
                }
        }
Class Torneo:
@Entity
public class Torneo {
        /*
         * @author Lisandro della Croce
         */
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Key id;
        @Basic
        private String nombre;
        @Basic
        private String imagen;
        @Basic
        private Date fechaInicio;
        @Basic
        private Date fechaFin;
        @Basic
        private List<FechaNormal> fechasTorneo;
        @OneToMany(cascade = {CascadeType.PERSIST,
CascadeType.REMOVE,
                    CascadeType.REFRESH, CascadeType.ALL})
        private List<Equipo> equiposTorneo;
        .....
Class Equipo:
@Entity
public class Equipo  {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Key id;
        @Basic
        private String nombre;
        @Basic
        private String imagen;
        @Basic
        private String desc;
        ......
Solution?
Regards
Lisandro

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to