Hello all :)
Sorry for maybe stupid question, but cannot understend where the
problem is.
I got 2 simple classes:
import javax.jdo.annotations.*;
import java.util.List;
import com.google.appengine.api.datastore.Key;
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Root {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
public Key getKey() {
return key;
}
public void setKey(Key key) {
this.key = key;
}
@Persistent
private String name;
@Persistent(mappedBy = "root")
private List<Tag> tags;
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
import javax.jdo.annotations.*;
import com.google.appengine.api.datastore.Key;
import java.util.List;
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Tag {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
public Key getKey() {
return key;
}
public void setKey(Key key) {
this.key = key;
}
@Persistent
private String name;
@Persistent
private Tag parent;
@Persistent
private List<Tag> children;
@Persistent
private Root root;
public List<Tag> getChildren() {
return children;
}
public void setChildren(List<Tag> children) {
this.children = children;
}
public Tag getParent() {
return parent;
}
public void setParent(Tag parent) {
this.parent = parent;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Root getRoot() {
return root;
}
public void setRoot(Root root) {
this.root = root;
}
}
Root class maps owned collection of Tags, then I make them persistent
like this:
PersistenceManager pm = PMF.get().getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Root motoRoot = new Root();
motoRoot.setName("moto");
Tag newTag1 = new Tag();
Tag newTag2 = new Tag();
newTag1.setName("test1");
newTag2.setName("test2");
motoRoot.setTags(new ArrayList<Tag>());
motoRoot.getTags().add(newTag1);
motoRoot.getTags().add(newTag2);
pm.makePersistent(motoRoot);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
And after this dataviewer shows only Root saved into database and
there no errors in log :(
Please help to get this thing working.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---