Delete an object by key without first extracting it in the application engine (using JDO)

Is there a way to delete an object without having to retrieve it from the data store? I assume that I already have a key or identifier for the object. I am thinking of something like deleteObjectByIdthat would be analogous getObjectByIdto PersistenceManager.

The closest I can think of is using Query.deletePersistentAll()(as shown here ) and specifying a request that depends only on the key, but I cannot say whether it will be possible to delete the object before deleting it.

thanks

EDIT: I know how to do this using the low level API as well as the python API. I was wondering if there is a way to do this in the JDO layer.

+3
source share
3 answers

datanucleus answered my question in google group :

Not really. The problem is that an object can have a relationship, and therefore, since they can cause a cascade of operations, it usually needs to be loaded into memory first. The only situation where he did not need to be loaded into memory was if the class of the object to be deleted had no relationship.

Switching to a low-level API and explosive objects may or may not affect related objects ... maybe someone is responsible for he could comment on this.

+2
source

JDO, Python . "" , . .

instance = Model(key=key_to_delete, required_property='dummy')
instance.delete()
+2

API ?

, DataService.delete(Key) , .

, KeyMaker .

Key k = KeyFactory.createKey(Employee.class.getSimpleName(), "Alfred.Smith@example.com");
0

Source: https://habr.com/ru/post/1722199/


All Articles