Hi Stevko! The class "Torneo", it's definite:
@PersistenceCapable(identityType=IdentityType.APPLICATION,detachable="true")
public class Torneo implements Serializable {
/*
* @author Lisandro della Croce
*/
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
private String nombre;
......
@Persistent(defaultFetchGroup = "true")
private List<Equipo> equiposTorneo;
Is correct?
Regards
On Jan 3, 9:06 am, "A. Stevko" <[email protected]> wrote:
> I think the inconsistent saving that you are experiencing has to do with how
> the parent object, Torneo, is being accessed.
> You are passing an database object reference into a transaction.
> Is that object "detachable" ?
>
> If not, then you should be retrieving it and updating it within the same
> transaction.
> See Updating an Object
> inhttp://code.google.com/appengine/docs/java/datastore/creatinggettinga...
>
> If so, then you should re-attach it prior to updating
> it.http://www.jpox.org/docs/1_2/jdo/attach_detach.html
>
> Hope this helps.
> --Andy
>
>
>
>
>
> On Mon, Jan 3, 2011 at 3:47 AM, lisandrodc <[email protected]> wrote:
> > 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 for Java" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-appengine-java%2B
> > [email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?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 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.