IllegalArgumentException: Can not set java.time.LocalDateTime field to java.sql.Timestamp

Alfred Moon

I am doing test task for a self-teaching. My stack is Spring Boot/H2 date base/Hibernate

I have like a REST-full service (actually it is not, now I am trying to fix it)

I've been told that I have a lot of bad code decisions and mistakes, so I've decide to fix it. Initial state of a working project is there - https://github.com/iliapastushenko/testtaskREST

I've started to refactor that and first thing that I've made - got rid of jackson-datatype-jsr310 because it is actually redundant thing for me - I've deleted it from POM and ClientappApplication class and edited my Application class field "dateCreated":

@DateTimeFormat(pattern = "dd-MM-yyyy hh:mm:ss")
@Type(type="timestamp")
private LocalDateTime dateCreated;

So, when I am trying to get one application of needed client via frontend I get this type of Exception:

java.lang.IllegalArgumentException: Can not set java.time.LocalDateTime 
field root.Model.Application.dateCreated to java.sql.Timestamp

Could you please give me a hint - what is wrong ?

Alfred Moon

Fixed it by property:

<hibernate.version>5.2.12.Final</hibernate.version>

So, since Hibernate 5.2 everything is okay with LocalDateTime, not Hibernate 5.0 as I was told earlier.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related