What a good solution? I could implement my own Duration class, but I donโt know how to force the JPA to โacceptโ it as a data type.
JPA , , , JPA . , Hibernate , @Type. , , . , , .
JPA getter/setter, . Long :
public MyEntity implements Serializable {
private Long id;
private javax.xml.datatype.Duration duration;
@Id
@GeneratedValue
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
@Transient
public Duration getDuration() {
return this.duration;
}
public void setDuration(Duration duration) {
this.duration = duration;
}
public Long getDurationAsJpaCompatibleType() {
return MyXmlUtil.convertDurationToLong(this.duration);
}
public void setDurationAsJpaCompatibleType(Long duration) {
setDuration(MyXmlUtil.convertLongToDuration(duration));
}
}