I can understand why this might seem to work. The problem I see is that unTomeo was detached from the database and either needs to be reattached or refetched before adding unEquipo to it.
Here is some documentation that may help explain. http://www.jpox.org/docs/1_1/attach_detach.html try this tx.begin(); pm.makePersistent(unTorneo); unTorneo.agregarEquipo(unEquipo); tx.commit(); On Fri, Oct 29, 2010 at 6:22 PM, lisandrodc <[email protected]> wrote: > Hi ! I have a problem with persist a class. The problem is that > sometimes, persist and sometimes not persist the class "Equipo" . I > have a persist class "Torneo" that has to many class "Equipo", and > when persist "Equipo" sometimes persist in the datastore and sometimes > not persist. > I have to try restarting the application in order that sometimes it > work. Someone will be able to help me? > The code to persist: > > public void agregarEquipoConTorneo(Torneo unTorneo, Equipo unEquipo) > { > /*add Equipo with a existing "Torneo" in the datastore, the > "unTorneo"(param) class obtain with: Torneo b = > pm.getObjectById(model.Torneo.class, idTorneo);*/ > Transaction tx = pm.currentTransaction(); > > try { > tx.begin(); > > unTorneo.agregarEquipo(unEquipo); > //pm.makePersistent(unEquipo); > > pm.makePersistentAll(unTorneo); > > tx.commit(); > > System.out.println("persistioTorneoConEquipo"); > } finally { > pm.close(); > if (tx.isActive()) { > tx.rollback(); > } > } > > } > > Regards > > -- > 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 > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine-java%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > > -- 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 [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-java?hl=en.
