Hallo,

I'm new to gae and I'm a bit confused with the way the datastore is
handling transactions. I believe that all in all I have figured out
how it works but unfortunatly I receive Exceptions. So this is the
problem: Three Class AbtractAdd DetailedAdd and AddConcept have to be
in the same Entitygroup for they are changed in one transaction.  Here
is some code that i believe is most important:

public class AbstractAdd implements Serializable{

        private static final long serialVersionUID = 1061921369184491066L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Extension(vendorName = "datanucleus",
                        key = "gae.encoded-pk", value = "true")
        private String keyString;

.....
}

public class DetailedAdd implements Serializable{

        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Extension(vendorName = "datanucleus",
                        key = "gae.encoded-pk", value = "true")
        private String keyString;
        @Basic
        @Extension(vendorName="datanucleus", key="gae.parent-pk",
value="true")
        private String abstractAddKey;

....
}

public class ConceptData implements Serializable{

        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Extension(vendorName = "datanucleus",
                        key = "gae.encoded-pk", value = "true")
        private String keyString;
        @Basic
        @Extension(vendorName="datanucleus", key="gae.parent-pk",
value="true")
        private String abstractAddKey;
...
}

first I save a abstractAdd object (em.persist(a)) then I assign the
key of the abstract addObject to the abstractAddKey fields of the
other two class. I believed that this way I establishet the entity
group so that I can save the detailedAdd Object and the ConceptData
object in one transaction. But this raises an exception that I can
only modify objects that belong to the same entity group. Please help
me out.

AbstractAdd abstractAdd = request.getAbstractAdd();
                DetailedAdd detailedAdd = request.getDetailedAdd();
                ConceptData conceptData = request.getConceptData();

                em.persist(abstractAdd);

                detailedAdd.setAbstractAddKey(abstractAdd.getKeyString());
                conceptData.setAbstractAddKey(abstractAdd.getKeyString());

                em.persist(detailedAdd);
                em.persist(conceptData);

                ....
}

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