Hibernate: general JDBC exception - bad format for 838: 59: 59 'time

I have a hibernation mapping as follows:

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

here this formula returns some value in this format "838: 59: 59" from my data.

I got an exception when I try to load this value into the "Duration" field, which is of type "java.sql.Time", it gives me this exception.

"Generic JDBC exception - Bad format for Time '838:59:59'"
+5
source share
3 answers

. java.sql.Time , , 24 , . , .

+3

MySQL, TIMESTAMPDIFF() UNIX_TIMESTAMP():

, TIMEDIFF(), , TIME. TIMESTAMPDIFF() UNIX_TIMESTAMP(), .

The query may look something like this, but depends on the data type of the result you are using:

SELECT FROM_UNIXTIME(TIMESTAMPDIFF(SECOND,sstime,NOW())) FROM time_table;

SELECT FROM_UNIXTIME(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(sstime)) FROM time_table;

Demo

+1
source

All Articles