I can't seem to cascade delete anything... any ideas?
AppEngine/Java 1.2.5
Attempt was made to modify the primary key of an object of type
com.examplel.data.Item identified by key Location("FOO")/Menu(10)/Item
(11) Primary keys are immutable. (New value: Item(11)
org.datanucleus.exceptions.NucleusUserException: Attempt was made to
modify the primary key of an object of type
com.aerva.client.mcd.portal.data.Item identified by key Location
("FOO")/Menu(10)/Item(11) Primary keys are immutable. (New value:
Item(11)
at org.datanucleus.store.appengine.DatastoreFieldManager.storeKeyPK
(DatastoreFieldManager.java:639)
at
org.datanucleus.store.appengine.DatastoreFieldManager.storePKIdField
(DatastoreFieldManager.java:450)
at
org.datanucleus.store.appengine.DatastoreFieldManager.storeObjectField
(DatastoreFieldManager.java:751)
at org.datanucleus.state.AbstractStateManager.providedObjectField
(AbstractStateManager.java:1037)
Code (First version):
// Already retreived object to be deleted:
Location location = ...;
PersistenceManager pm = PMF.get().getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
pm.deletePersistent(location);
tx.commit();
return Response.noContent().build();
}
finally {
if (tx.isActive())
tx.rollback();
}
Code (Second version):
PersistenceManager pm = PMF.get().getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Query q = pm.newQuery(Location.class);
q.setFilter("id == '" + loc.getId() + "'");
q.deletePersistentAll();
tx.commit();
return Response.noContent().build();
}
finally {
if (tx.isActive())
tx.rollback();
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---