Here's my code to delete all entities for a given type:
@Override
public boolean deleteEntities(String instance, final String storeName) {
final boolean[] success = {false};
final PersistentEntityStore entityStore = manager.getPersistentEntityStore(xodusRoot, instance);
try {
entityStore.executeInTransaction(new StoreTransactionalExecutable() {
@Override
public void execute(@NotNull final StoreTransaction txn) {
EntityIterable result = txn.getAll(storeName);
final boolean[] hasError = {false};
for(Entity entity : result) {
if(!entity.delete()) {
hasError[0] = true;
}
}
success[0] = !hasError[0];
}
});
} finally {
////entityStore.close();
}
return success[0];
}
Question:
There is PersistentEntityStore#renameEntityType
to rename entity type as part of a public api. To delete entity type at all you can use PersistentEntityStoreImpl#deleteEntityType
. It's not a part of PersistentEntityStore
api but method is public and you can use it.
Also when you deleting entity type do not forget that you also need to clear all links points to entities of this type.