Home  >  Q&A  >  body text

MAX(CONVERT(column, TIME(3))) returns different values ​​from mysql client than JPA native query

MAX(CONVERT(column, TIME(3))) The value returned from the mysql client is different from the value returned by the JPA native query. The first one is returning (in my sample data) the correct value 47:40:00.000, but the JPA native query returns 23:40:00 and don't know why since it has the native query flag.

P粉333395496P粉333395496399 days ago961

reply all(1)I'll reply

  • P粉270842688

    P粉2708426882023-09-17 10:58:19

    The problem is because of the conversion from local time format (equivalent to sleep time) to string. I solved the problem of converting to string on MySQL.

    @Query(value = "SELECT CAST(MAX(CONVERT(v.start,TIME(3))) AS CHAR) FROM variable v WHERE v.well IN ?1 ", nativeQuery=true);

    reply
    0
  • Cancelreply