Hibernate:通用JDBC异常 - 时间'838:59:59'的格式错误

Har*_*ani 5 java mysql hibernate

我有hibernate映射如下:

<property formula="(Timediff(ifnull(sttime,now()),sstime))" insert="false" name="duration" update="false" />
where sstime is of type Timestamp
Run Code Online (Sandbox Code Playgroud)

这个公式从我的数据中以这种格式"838:59:59"返回一些值.

当我试图在"持续时间"字段中加载此值时出现异常,该字段具有"java.sql.Time"类型,它给了我这个例外.

"Generic JDBC exception - Bad format for Time '838:59:59'"
Run Code Online (Sandbox Code Playgroud)

JB *_*zet 3

这确实不是一个有效的时间。您不应该使用 java.sql.Time 来表示持续时间,特别是如果该持续时间可能长于 24 小时,因为 Time 表示日期的时间部分。请改用自定义类型,或者只是您自己解析的字符串。