Now with "pm.makePersistentAll(dbTorneo)" ,
it sometimes  work and  sometimes not work. if I follow your steps
Stevko (without the line
"pm.makePersistentAll(dbTorneo)") ,
besides which he does not persist, on having added the second element,
throws the exception:

Collection field "model.Torneo.equiposTorneo" has been specified to
contain the element "model.equ...@1292d12" unembedded yet this is
already identified as being stored embedded in a different field. This
is invalid. You cant store the same object embedded and unembedded!
Caused by:
javax.jdo.JDOUserException: Collection field
"model.Torneo.equiposTorneo" has been specified to contain the element
"model.equ...@1292d12" unembedded yet this is already identified as
being stored embedded in a different field. This is invalid. You cant
store the same object embedded and unembedded!

Help me?
Thanks!


On Jan 4, 9:30 am, lisandrodc <[email protected]> wrote:
> 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