Hi!
 Torneo dbTorneo = pm.makePersistent(unTorneo);
 dbTorneo.agregarEquipo(unEquipo);
 ....
Following this step one does not add in the base an object "unEquipo"
I had to add immediately afterwards to these lines immediately:
pm.makePersistentAll(dbTorneo)

This way if persite the objects of the collection, which seems to me
mas
logically of being necessary the makePersistent. Some suggestion?

Thanks
Regards


On Jan 3, 4:02 pm, "A. Stevko" <[email protected]> wrote:
> This is not the most elegant or efficient way to do things but here is
> something to make your code work.
>
>       public Torneo devolverTorneo(Long idTorneo) {
>            Torneo dbTorneo = pm.getObjectById(Torneo.class, idTorneo);
>            // detach a copy of the persistent object
>            return pm.detachCopy(dbTorneo );
>        }
>
>        public void agregarEquipoConTorneo(Torneo unTorneo, Equipo
> unEquipo) {
>                Transaction tx = pm.currentTransaction();
>
>                try {
>                    tx.begin();
>                    // sync unTorneo with database before changing it
>                    Torneo dbTorneo = pm.makePersistent(unTorneo);
>                    dbTorneo.agregarEquipo(unEquipo);
>                    /*add an "Equipo" to collection "equipos" That has
> the class "Torneo"
>                    Debugs adds, but sometimes he does not persist*/
>
>                    tx.commit();
>                     System.out.println("persistioTorneoConEquipo");
>                } finally {
>
>                        if (tx.isActive()) {
>                                tx.rollback();
>                        }
>
>                }
>        }
>
> Another way to do all this is to redesign your ControladorTorneo class to
> only store the ID of the Torneo and fetch it from the database in the
> transaction you want to change it.
>  public void agregarEquipoConTorneo(  torACargar, Equipo unEquipo)...

-- 
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