Reputation: 8480
I have a persistent object that has a huge list of child elements. I'm trying to add a new element, but to retrieve the list i spent a lot of read operations. How can I add this elements without get the list?
I'm using something like this:
PersistenceManager pm = PMF.get().getPersistenceManager();
ObjectX obj= pm.getObjectById(ObjectX.class, id);
obj.getChildrenElements().add(newChild);
Upvotes: 0
Views: 78
Reputation: 3115
I am not sure there is another way to do this. Instead, maybe you could try to change the way you model the relationships. Thus, instead of keeping a list of children for each object, you could specify to each of the children a parent. This relationship doesn't have to be owned if you don't need the parents and the children to belong to the same entity group.
Hope that helps!
Upvotes: 1