Using the JDO persistence, I'd prefer to work with detached objects so
that I don't have to spew and chew DTOs all over the codebase. I did
some searching for "detached," but found no topics. I've set the PMF
property for detachAllOnCommit(true). A simple JUnit test blows up
with the following sequence:
1. Parent p = new Parent();
2. pm.makePersistent(p) ; // Inside a transaction
3. Child c = new Child();
4. p.add(c);
5. pm.makePersistent(p); // Inside separate transaction
(It works if you omit step 2, but children will be added a after the
parent has been persisted, steps 3-5 could happen days later)
javax.jdo.JDOFatalUserException: Illegal argument
NestedThrowables:
java.lang.IllegalArgumentException: can't operate on multiple entity
groups in a single transaction. found both Element {
type: "Parent"
id: 91
}
and Element {
type: "Child"
id: 92
}
I understand the multiple entity group limit within a single
transaction, but why are they in separate groups?
It's as if c is persisted without knowledge that it is p's child,
despite being found by traversing the persistent
one-to-many field in the parent. It's handled correctly if both
parent and child transition from transient to persistent
together.
Reading the docs, I assume I could force the seeding the Entity Group
Parent ID component in c.id with either
1. Child c = new Child(p); or inside
2. p.add(c);
but then my objects are no longer POJOs, they're tightly coupled to
datastore, and I'd have to call out to persistence/transaction layer
in my child constructor (not a good idiom) or in my parent collection
mutator (needlessly chatty to the back end). Am I missing something
basic here? It seems like I should be able to do this.
Any help would be appreciated.
Also, kudos to whoever wrote the code that tossed the IAE, it's a very
clear error message.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---