CPA
CPA

Reputation: 3053

IntelliJ persistence tool type mapping

I have a PostgreSQL database schema. And I am trying to generate JPA entities from that schema in IntelliJ with the integrated persistence tool. Everything works fine, except the mapping of timestamps.

The persistence tool is trying to map the PostgreSQL TIMESTAMP data type to java.lang.Object or java.io.Serializable. I can't change the mapping to LocalDateTime, String or anything else.

Is there any way to set the correct mapping types?

UPDATE:

I get the following exception:

SchemaManagementException: Schema-validation: wrong column type encountered in column [timestamp] in table [ProcessEvent]; found [timestamptz (Types#TIMESTAMP)], but expecting [bytea (Types#VARBINARY)]

Upvotes: 0

Views: 459

Answers (1)

Tobias Otto
Tobias Otto

Reputation: 1676

Have you used the proper annotation for the attribute?

@Entity
public class Employee {
    ...
    @Basic
    @Temporal(DATE)
    private Calendar startDate;
    ...
}

Please see: https://en.wikibooks.org/wiki/Java_Persistence/Basic_Attributes#Temporal.2C_Dates.2C_Times.2C_Timestamps_and_Calendars

Upvotes: 1

Related Questions