What type of MySQL to use for java.time.ZonedDateTime

1) How many columns do I need in a MySQL database to store java.time.ZonedDateTime ?

2) DATETIME vs TIMESTAMP MySQL Types - which is better to store ZonedDateTime and LocalDateTime

Based on this article, PersistentDateTimeTZ is used to store joda DateTime in 2 columns. So I expect that I will have the same thing, but when I try to use

@Columns(columns={@Column(name="transaction_date"),@Column(name="transaction_date_tz")})
    @Type(type = "org.jadira.usertype.dateandtime.threeten.PersistentZonedDateTime")
    private ZonedDateTime transactionDate;

I get an exception:

Caused by: org.hibernate.MappingException: property mapping has wrong number of columns: my.package.Transaction.transactionDate type: org.jadira.usertype.dateandtime.threeten.PersistentZonedDateTime
    at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:484)
    at org.hibernate.mapping.RootClass.validate(RootClass.java:270)

PS

hibernate-version 4.2.7.Final

jadira version 4.0.0.GA

+4
source share
1 answer

This is a tiny blob. He just worked with Grails3.

0

Source: https://habr.com/ru/post/1612086/


All Articles