0

I am working with a legacy GAE system, using JDO 2.3, which does not use entity groups, but I now wish use entity groups, to take advantage of transactions. Having added a one-to-many relationship on two entity types, this works correctly for new entities created, but causes problems when working with existing legacy entities without the parent-child relationship (unable to delete the child entity).

How do I migrate the existing legacy entities to use the new schema? I have tried updating the parent on the child classes but received a org.datanucleus.store.appengine.DatastoreRelationFieldManager$ChildWithoutParentException ... A parent cannot be established or changed once an object has been persisted.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
kanghj91
  • 140
  • 1
  • 9

1 Answers1

1

First, you can still use Transactions outside of an entity-group - it's called cross-group transactions (XG transactions). You are limited to 25 entity groups in the transaction though.

Note: in your case, every entity is an entity group.

The entity-group of an entity is an immutable property defined at creation time. What this means is that you would need to delete and then write a new entity with the correct parent set, in a transaction of course.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
  • Ah yes, I am aware of XG transactions. I should have clarified in my original question that I need transactions involving more than 25 entities :D. Nevertheless, your second part of the answer was what I needed. I was hoping there would be a way to do without creating a new entity type though, because the encoded-pk of the original entity was getting used and stored in business logic and other entities. – kanghj91 Jun 08 '16 at 02:24