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]>
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%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].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.