The CQL Insert statement creates the statement first with existing entity and THEN executes the onBeforeSave. However, the rest of the flow will use the insert statement that was already created thus not being able to use the new version of the entity.
DATACMNS-1467 Add API for entity callbacks/change before save/after load
DATACASS-4 Implement Auditing
("is depended on by")
This is expected behavior. BeforeSaveEvent is fired right before executing the Statement. We probably should introduce BeforeConvertEvent to reflect event-based entity changes in the INSERT/UPDATE statement.
BeforeSaveEvent gives you access to a statement. We're considering a generic entity callback API that expresses entity mutation support. Right now, events are immutable and if the entity class is immutable as well, there would be no chance of updating an entity prior to saving.