Hello again,

I cannot give you straightforward answer,
try to do as little as possible. Create simple entity,
try to create new, delete some by key, createIfNotExists and similar
DAO methods. Do not put any nontrivial logic to this DAO.

Also make sure you entities have "right" key type and such,
your crearPartido method has somehow too many arguments try to make it
more simple.

step by step.




On Jul 22, 12:37 am, lisandrodc <lisandr...@gmail.com> wrote:
> Hi!Marcus, now I use your pattern for transactions:
> The code of the method:
> public void crearPartido(Long idEqLocal, Long idEqVisitante, Date
> fecha,
>                         Fecha fechaAgreg, String resultado, String hora,Long 
> idTorneo){
>
>                 PersistenceManager pm = 
> JDOHelper.getPersistenceManager(fechaAgreg);
>
>                 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();
>                 }
>
>         }
>
> But now, the error is:
>
>  "Object with id "com.google.appengine.api.datastore.Key:Torneo(1)/
> Equipo(3)" is managed by a different Object Manager".
>
> I try also changed in the code:
>  "PersistenceManager pm = getPersistenceManager();
> For:
> "PersistenceManager pm =
> JDOHelper.getPersistenceManager(fechaAgreg);"(But mistake is the one
> that already I enunciated).
> The 
> link:http://stackoverflow.com/questions/1403515/appengine-datastore-object...
> Regards
> Lisandro
>
> On 19 jul, 05:15, Marcus Brody <mhrab...@gmail.com> wrote:
>
> > try follow this pattern for transactions
>
> > public void doSomthingWithEntity(T entity) {
>
> >                 PersistenceManager pm = getPersistenceManager();
> >                 Transaction transaction = pm.currentTransaction();
>
> >                 try {
> >                         transaction.begin();
> > //                      do something with entity, get, persist, delete
> > //                      pm.makePersistent(entity);
>
> >                         transaction.commit();
> >                 }
> >                 finally {
> >                         if (transaction != null && transaction.isActive())
> > transaction.rollback();
> >                         pm.close();
> >                 }
> >         }
>
> > On Jul 18, 11:01 pm, lisandrodc <lisandr...@gmail.com> wrote:
>
> > > Hi! I have a problem with active transaction.When I try to guard in
> > > the datastore, says:
>
> > >  "La transaccion esta activo todavia. Debe cerrar las transacciones
> > > usando los metodos commit() o rollback()."
>
> > > As closure all the transactions?
> > > The method is:
>
> > > PersistenceManager pm2 = JDOHelper.getPersistenceManager(fechaAgreg);
>
> > >                 Transaction tx = pm2.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);
>
> > >                         fechaAgreg.agregarPartido(par1);
> > >                         pm2.makePersistent(fechaAgreg);
> > >                         tx.commit();
>
> > >                 } finally {
> > >                         pm2.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 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