postgresqlhibernateeclipselinkpayara-micro

How to save LocalDate to Postgres with Payara Micro


I am getting the below error when I try to persist a LocalDate column. The error only occurs when the field is null. The publish_date column is of type Date in the database.

I check Bug 535431 and Bug 546312 and apparently the issue is supposed to have been resolved with version 2.7.6 but it is still occurring.

Error:

Caused by: org.postgresql.util.PSQLException: ERROR: column "publish_date" is of type date but expression is of type character varying

Entity:

@Entity
@Table(name = "book")
public class Book {

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "publish_date")
    private LocalDate publishDate;
    ...

Solution

  • I found a work around to this. I added &stringtype=unspecified to the end of the JDBC-URL but I am not sure what the issue is:

    <url>jdbc:postgresql://localhost:5432/library?currentSchema=books&amp;stringtype=unspecified</url>