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 <[email protected]> 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 [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.

Reply via email to