Many modern ORMs provide access to previous state in lifecycle hooks:
- Entity Framework: entry.OriginalValues
- Ruby on Rails: attribute_was
- Sequelize: _previousDataValues
JPA requires complex workarounds (Interceptors/Envers) for this common use case.
Proposed API:
@PreUpdate
public void beforeUpdate(EntityState state) {
Object oldValue = state.getOriginalValue("name");
Object newValue = this.name;
}