1

This code below is our code to delete property for a given Entity type:

@Override
public boolean deleteProperty(String instance, String storeName, String propertyName) {
    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 entities = txn.findWithProp(storeName, propertyName);
                final boolean[] hasError = {false};
                entities.forEach(entity -> {
                    if(!entity.deleteProperty(propertyName)) {
                        hasError[0] = true;
                    }
                });
                success[0] = hasError[0];
            }
        });
    } finally {
        //entityStore.close();
    }
    return success[0];
}

I understand that Xodus is transactional and that if one of the deleteProperty operation here fails it will roll back (I may need to know if this is confirmed).

Still, is there a official way to delete a property for all existing entities of a given type?

quarks
  • 33,478
  • 73
  • 290
  • 513

1 Answers1

1

I understand that Xodus is transactional and that if one of the deleteProperty operation here fails it will roll back (I may need to know if this is confirmed).

Yes, it's true. Here transaction will be flushed after StoreTransactionalExecutable performs there job. But you can split EntityIterable into batches (of size 100 for example) and after processing each batch execute txn.flush() method. Do not forget to check flush result since it returns boolean.

Still, is there a official way to delete a property for all existing entities of a given type?

No, there isn't. Only manually like I described above.

lehvolk
  • 233
  • 1
  • 4