Hi,
My application is currently using JDO, although for some stress
testing
I am trying to employ batch insert using low level API (since it is
less practical to do it with JDO).
I have JDO parent-child one to many model which I am trying to insert
using the low level API "Entity" model.
So far I have succeeded to batch insert the entities although failed
in making the relationship.
Is it possible to accomplish a parent-child one to many relationship
using Entity API ?
Short Example:
-------------------
// One Question has Many Answers
@PersistenceCapable (detachable = "true")
public class Question implements Serializable {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
private String key;
@Persistent(mappedBy = "question")
@Element(dependent = "true")
private List<Answer> answers;
......
}
@PersistenceCapable (detachable = "true")
public class Answer implements Serializable {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
private String key;
@Persistent
private Question question;
....
}
// Using low level API
Entity question = new Entity("Question");
Entity a1 = new Entity("Answer",question.getKey());
....
Entity a2 = new Entity("Answer",question.getKey());
...
DatastoreService dataStore =
DatastoreServiceFactory.getDatastoreService();
Transaction txn = dataStore.beginTransaction();
dataStore.put(question);
dataStore.put(a1);
dataStore.put(a2);
txn.commit();
//END
Thanks
Luka
--
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.