我有以下JPA实体:
@Entity
public class Notification {
private Duration deliveryTimeLimit;
public Duration getDeliveryTimeLimit() {
return deliveryTimeLimit;
}
public void setDeliveryTimeLimit(Duration deliveryTimeLimit) {
this.deliveryTimeLimit = deliveryTimeLimit;
}
}
我想将持续时间存储到数据库。
我应该在Oracle数据库中使用什么数据类型?
[当我选择NUMBER
时,当从csv文件加载数据时,我必须将1 minute
指定为60000000000 nanoseconds
。
INTERVAL DAY TO SECOND数据类型是您的朋友。请参阅:How to represent Oracle Interval in Java
此外,您可以检查Oracle数据库数据类型:https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Data-Types.html#GUID-F8686599-B7AE-477D-8A58-FA0AA8B2C348
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select interval '1' minute from dual;
INTERVAL'1'MINUTE
---------------------------------------------------------------------------
+00 00:01:00