I have migrated JDO to JPA (Due to the problem of persistence), but it
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 for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to