次のクラスがあるとしましょう。
@Entity
public class ShiftDetail {
@Id
private Integer id = null;
private String name = null;
private LocalTime startTime = null;
private LocalTime endTime = null;
public Duration getShifDurationInSeconds() {
return Duration.between(this.startTime, this.endTime).toSeconds();
}
}
ダウンザライン処理を簡単にするために、派生値「ShiftDurationInSeconds」をデータベースに保存したいと思います。
クラスに属性を作成せずに JPA/Hibernate でこれを行う方法はありますか?