Unfortunately, JPA still does not support the types of the new java.time package
However, you have several methods ( toString and parse ) that provide you with a path by converting to String; vg
@Transient private Duration myDuration; @Column(name="DURATION") String myDurationString; @PostLoad public void init() { this.myDuration = this.myDurationString == null ? null : Duration.parse(this.myDurationString); }; public Duration getMyDuration() { return this.myDuration; } public void setMyDuration(Duration _myDuration) { this.myDurationString = _myDuration == null ? null : _myDuration.toString(); }
Remember that you should not include getters and receivers for myDurationString .
Optionally, you can use toMillis() and ofMillis() if you prefer a number in milliseconds.
source share