Hello, everybody!
I have simple one to many owned relationship:
...
class MyList{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent(mappedBy="myList")
@Element(dependent = "true")
List<Item> items;
...
}
class Item{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key id;
@Persistent
MyList myList;
...
}
When I add new Item I do
tx.begin();
Key key = getParentKey();
MyList myList = pm.getObjectById(MyList.class, key);
Item item = new Item();
item.setMyList(myList);
myList.items.add(item);
tx.commit();
It works. But there are couple things which bother me. First at all,
there is some extra job here. I actually don't need instance of parent
class (MyList).
I have the parent key. Theoretically speaking, it is the only thing
needed to maintain parent child relationship. MyList class may have
more fields I don't need at all. So, I'd like to avoid reading them to
memory.
Second concern is about line
myList.items.add(item);
what if MyList already has million of items? How efficient is add
operation in this case?
Any thoughts? Is it possible to store child object using parent key
only?
Thank you,
Andrey
--
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.