Hi Stevko!
-unTorneo.getEquiposTorneo() , return a collection"List" of objects
"Equipo".
-unTorneo is retrieved by pm.getObjectById(MyObject.class, myId );.
The problem is that sometimes he persists and sometimes he does not
persist.
 I hope that it uses as help and could help me...
Thanks.
Happy Year!
Regards


On 31 dic 2010, 18:38, "A. Stevko" <[email protected]> wrote:
> Hello Lisandro,
> What I don't see is how you are retrieving the persisted object from the
> database.
> What does "unTorneo.getEquiposTorneo()" do?
>
> Using JDO, I'm used to working with a PersistenceManager object and writing
> transactions with a template like this...
>
> // inject the PersistenceManager dependency
> private final Provider<PersistenceManager> pmp;
> ....<snip>
> PersistenceManager pm = pmp.get();
> try {
> pm.currentTransaction().begin();
>
>               MyObject my = pm.getObjectById(MyObject.class, myId );
>                         // update object here
>
> pm.currentTransaction().commit();
>
> } catch (javax.jdo.JDOObjectNotFoundException e) {
>
> //
> logger.warning( "Object not found - id=" + myId );
> pm.currentTransaction().rollback();
>
> } finally {
>
> if (pm.currentTransaction().isActive()) {
> logger.severe("Database exception!! - id=" + myId );
> pm.currentTransaction().rollback();
>
>
>
> }
> }
> On Thu, Dec 30, 2010 at 4:43 AM, lisandro <[email protected]> wrote:
> > Hi! Ikai, I have tried but it me did not work:
> > I have tried but it me did not work.
> > The modified code:
>
> >            tx.begin();
> >            JDOHelper.makeDirty(unTorneo.getEquiposTorneo(),
> > "equiposTorneo");
> >            List<Equipo>listEquipos = unTorneo.getEquiposTorneo();
> >            unTorneo.setEquiposTorneo(listEquipos);
> >            unTorneo.agregarEquipo(unEquipo);
> >            pm.makePersistent(unTorneo);
> >            tx.commit();
>
> > Thanks!
> > Regards
>
> > On Dec 29, 4:58 pm, "Ikai Lan (Google)" 
> > <[email protected]<ikai.l%[email protected]>
>
> > wrote:
> > > Objects are re-persisted if there are any fields that are marked "dirty".
> > > Sometimes, when you add objects to a collection property, since the
> > property
> > > reference may not be marked "dirty", it will not be repersisted when the
> > > PersistenceManager is closed. You can either:
>
> > > 1. Call JDOHelper.makeDirty(entity, field) to mark the field as dirty
> > > 2. Create a new, equivalent collection and point the equipos reference to
> > it
> > > 3. (98% sure this works) Change a value in another property, causing the
> > > entire Entity to be persisted (App Engine entities are persisted whole,
> > not
> > > piecemeal as you might do in a relational database)
>
> > > --
> > > Ikai Lan
> > > Developer Programs Engineer, Google App Engine
> > > Blogger:http://googleappengine.blogspot.com
> > > Reddit:http://www.reddit.com/r/appengine
> > > Twitter:http://twitter.com/app_engine
>
> > > On Wed, Dec 29, 2010 at 6:53 AM, lisandro <[email protected]> wrote:
>
> > > > lisandrodc
> > > > View profile
> > > >  More options Dec 29, 11:26 am
> > > > Hi! I have a problem with the persistence of an existing object
> > > > "Torneo" (with a empty collection of objects "Equipo").
> > > > When I add elements to the collection and want to persist,
> > > > sometimes persist and sometimes not persist in the
> > > > datastore(Restarting the server of the application). The code of
> > > > example:
> > > > public void agregarEquipoConTorneo(Torneo unTorneo, Equipo  unEquipo)
> > > > {
> > > >                /*add Equipo with a existing "Torneo" in the
> > > >               datastore, the  "unTorneo"(param) class obtain with:
> > > > Torneo b =
> > > >               pm.getObjectById(model.Torneo.class, idTorneo);*/
> > > >                Transaction tx = pm.currentTransaction();
> > > >                try {
> > > >                        tx.begin();
> > > >                        unTorneo.agregarEquipo(unEquipo);
> > > >                        //add unEquipo to collection "equipos"
> > > >                        pm.makePersistentAll(unTorneo);
> > > >                        tx.commit();
> > > > System.out.println("persistioTorneoConEquipo");
> > > >                } finally {
> > > >                         pm.close();
> > > >                        if (tx.isActive()) {
> > > >                                tx.rollback();
> > > >                        }
> > > >                }
> > > > Does it design someone of what this one happening?
> > > > Thanks!
> > > > Regards
> > > > Lisandro
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Google App Engine" group.
> > > > To post to this group, send email to [email protected]
> > .
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<google-appengine%[email protected]><google-appengine%2Bunsubscrib
> > [email protected]>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-appengine?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-appengine%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine?hl=en.
>
> --
> -- A. Stevko
> ===========
> "If everything seems under control, you're just not going fast enough." M.
> Andretti

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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?hl=en.

Reply via email to