Skip to content

Conversation

@rPraml
Copy link
Contributor

@rPraml rPraml commented Jul 23, 2025

We found an issue, where lazyLoad in preDelete of does not work in batch mode.

Example:

class BeanPersistController {
      public boolean preDelete(BeanPersistRequest<?> request) {
        assertThat(((EBasicVer) request.bean()).getDescription()).isEqualTo("MyDescription");
        return true;
      }
}


try (Transaction txn = db.beginTransaction()) {
      txn.setBatchMode(true);
      EBasicVer bean = db.find(EBasicVer.class).setUseCache(false).select("name").setId(id).findOne();
      db.delete(bean); // will remove bean from PC
      txn.commit(); // will invoke preDelete
}

What happens here:

Workaround

  • do not rely on lazyload of request.bean() and fetch data explicit with a query in preDelete (fromDb = DB.find(cls, request.bean().getId()))

Possible fix:

assertThat(master).isNotNull();
// CHECKME: Deleting of master was denied by the PersistListener
// What about detail? Is this intended, that it will be deleted?
assertThat(master.getDetails()).hasSize(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHECKME:
Can you tell me if the PersistController is intended to protect a bean from deletion? If so, then I would expect that if the deletion process was prevented by UtMaster, its details wouldn't be deleted.

But if you say the PersistController only takes care of the physical persistence, then that would be OK (although perhaps this should be explicitly mentioned again in the documentation for preInsert/Update/Delete).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant