I am not able to set the null value for the field described below. I want to insert NULL as the default value.
@Column(name = "answer_date",columnDefinition = "TIMESTAMP")
private LocalDateTime answerDate
When I set the NULL, it shows the following error:
Caused by: org.postgresql.util.PSQLException: ERROR: column "answer_date" is of type timestamp without time zone but expression is of type character varying
I am using EclipseLink as JPA implementation.
I think this is a known issue. Refer links
(typeorm also faces the same issue).
When you try to set the answerDate to null, it turns into a "null" string which is submitted to the postgres database and causes this error since "null" is not a valid timestamp format.
Its better if you assign a default value in case the LocalDateTime is not present.
In this case, this error message saying "is of type timestamp ... but expression is of type text.." can be avoided.
UPDATE The error is fixed in eclipseLink version 2.7.6 (https://github.com/eclipse-ee4j/eclipselink/pull/415)