Код: Выделить всё
@Entity
@EntityListeners(CarEntityListener.class)
public class Car {
@Column
private Long id;
@Column
private String status;
@Transient
private String loadedStatus;
}
class CarEntityListener {
@PostLoad
private void onLoad(Car car) {
car.setLoadedStatus(car.getStatus());
}
@PostUpdate
private void onUpdate(Car car) {
if (!car.getLoadedStatus().equals(car.getStatus()) {
// Do processing here
}
}
}
Код: Выделить всё
@PostUpdate
private void onUpdate(Car oldCar, Car newCar) {
if (!oldCar.getStatus().equals(newCar.getStatus()) {
// Do processing here
}
}
Подробнее здесь: https://stackoverflow.com/questions/708 ... g-entities
Мобильная версия