Hi! I have a problem with active transaction.When I try to guard in
the datastore, says:

 "Object with id "com.google.appengine.api.datastore.Key:Torneo(1)/
Equipo(3)" is managed by a different Object Manager".

Disegn:
A Torneo has relation one to many Equipo
A Fecha has relation one to many Partido

The method:
private static PersistenceManager pm =
PMF.get().getPersistenceManager();
//pm is a singleton
public void crearPartido(Long idEqLocal, Long idEqVisitante, Date
fecha,
                        Fecha fechaAgreg, String resultado, String
hora,Long idTorneo){

                PersistenceManager pm =
JDOHelper.getPersistenceManager(fechaAgreg);
//or Transaction tx = pm.currentTransaction();
                Transaction tx = pm.currentTransaction();

                try {
                        tx.begin();
                        Partido par1 = null;
                        ControladorTorneo cT= new ControladorTorneo();
                        par1 = new Partido(null, new
Resultado(),cT.devolverEquipo( idTorneo,idEqLocal),
cT.devolverEquipo(idTorneo,idEqVisitante), fecha, hora);
             /*In mode debug, is here below where accedes for the
block finally(with error)       */
                 fechaAgreg.agregarPartido(par1);

                        pm.makePersistent(fechaAgreg);
                        tx.commit();

                } finally {
                         if (tx != null && tx.isActive())
                                 tx.rollback();
                  pm.close();
                }

        }

And the method crearPartido is called for:
public String execute() throws Exception {

                ControladorFecha cF = new ControladorFecha();

                Fecha fechaSel = cF.devolverFecha(fecha, torParam);
                ControladorPartido cP= new ControladorPartido();
                cP.crearPartido(idEquipoLocal, idEquipoVisitante,
fechaPartido,fechaSel,resultado,hora,torParam);

                return SUCCESS;
        }

Thr method "devolverFecha":
private static PersistenceManager pm =
PMF.get().getPersistenceManager();
//pm is a singleton
public Fecha devolverFecha(Long idFecha, Long torneo) {

                Transaction tx = pm.currentTransaction();
                try {
                        tx.begin();
                        Key k2 = new 
KeyFactory.Builder(Torneo.class.getSimpleName(),
                                        
torneo).addChild(Fecha.class.getSimpleName(), idFecha)
                                        .getKey();

                        Fecha f = pm.getObjectById(Fecha.class, k2);

             tx.commit();
                        return f;
                } finally {
                        if (tx.isActive()) {
                                tx.rollback();
                        }
                        //pm.close();
                }
        }

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