I am using a transaction in Objectify 4 to update a bunch of entities, of Kind_A. These have a number of fields I want to modify within the transaction, but also a number of Refs to other entities, e.g.
class Kind_A {
@Id Long id;
@Parent
@Load
Ref<Kind_P> parent;
String name;
@Load
Ref<Kind_B> b;
}
My entity group here is defined by an instance of Kind_P, which will have its own Ref
s, e.g.:
class Kind_P {
@Id Long id;
@Load
Ref<Kind_Q> q;
}
In my transaction, I will ofy().load()
a number of entities as List using an ancestor query, like this:
ofy().load().type(Kind_A.class).ancestor(p).list();
I will then iterate the List, modify, say, the name
field (not the Ref<>
s), then ofy().save()
the List.
All the entities I load()
should have the same @Parent
(p
) since it's an ancestor query.
So, on the face of it, when I load()
and save()
my Kind_A
entities, I am dealing with a single entity group (p
).
However, I am getting an IllegalArgumentException: operating on too many entity groups in a single transaction
. I am guessing this is because Objectify is loading the object graph, including all the Kind_B
s and Kind_Q
s.
Is this correct? So the scope of the transaction is suddenly spreading well beyond the entity group defined by p
.
If so, is there a way to tell Objectify to ignore the @Load annotations inside a transaction?
Is there a way (in, say, the Eclipse debugger) I can find out the entities that are participating in the transaction?
Any insight would be much appreciated!
@Load
annotation on the@Parent
seems to resolve the issue, but I would like to know if this is expected, or coincidence. – tx802