Entity Events Before Commit

I am developing a tuition management module. I have 2 entities TuitionBill and TuitionBillItem with 1-n relationship. I want before deleting a TuitionBillItem to update the total amount of TuitionBill(amount). I based on the documentation given by the jmix developer but it seems to be incorrect or out of date. I would really appreciate it if you guys have any advice on how I can get TuitionBIll in my case.
Below is information on how I am doing. Thanks
Jmix Document : Entity Events :: Jmix Documentation

image

Debug:

image

Database:

image

Hi!
Try use AfterCommit event

1 Like

Thank for suggesting. I tried it but it didn’t work.

Hi @nguyencongphuong

The example in the docs works fine, I’ve just double-checked it.
Could you provide a test project where your problem is reproduced?

In beforecommit event, on deleting the entity both the examples in documentation and tutorial are not working and giving nullpointerexception. Please guide?

Ok. We cannot read the deleted entity in either beforecommit or aftercommit events. Thanks.

Sure. For EntityChangedEvent.Type.DELETED you can only get the deleted entity’s ID using event.getEntityId() and values of its attributes using event.getChanges().getOldValue("attr-name") (old values are the attribute values at the moment of loading the entity from the database).