(Spring app - MVC) I defined a table with the column:
`time` TIME NOT NULL,
In the entity class I have:
@Getter @Setter
@NotNull
private java.sql.Time time;
In my DTO class, I have:
@Getter @Setter
private java.sql.Time time;
When I send "time": "12:10"
from postman I get:
com.fasterxml.jackson.databind.JsonMappingException: Instantiation of [simple type, class java.sql.Time] value failed: null (through reference chain: (<points to a field (of java.sql.Time) in my aforementioned DTO class>))
When I have TIMESTAMP
in MySQL, java LocalTime
in both dto and entity, then it works but it persists both time and date. I would like to have time only.
I walked through different previous topics f.e. Joda-Time-Hibernate
so I used LocalTime
(in both dto and entity) with annotation @Type(type="org.joda.time.contrib.hibernate.PersistentLocalTimeAsTime")
but it didn't work.
Could someone help me, what are the right types (time only) for dto, entity, table's column, so jackson can serialize, hibernate understand and persist.