4

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

2) DATETIME vs TIMESTAMP MySQL types - what is better to store ZonedDateTime and LocalDateTime

Based on this article PersistentDateTimeTZ is used to store joda DateTime in 2 columns. So I expect to have the same for 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 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)

P.S.

hibernate-version 4.2.7.Final

jadira-version 4.0.0.GA

Andrew
  • 106
  • 5
  • Try TheKojuEffect's answer http://stackoverflow.com/questions/23718383/jpa-support-for-java-8-new-date-and-time-api – Bilal BBB Oct 17 '15 at 21:19
  • 1
    I saw this article before posting my question. It does not answer question what database column bype and columns number to use – Andrew Oct 19 '15 at 16:00

1 Answers1

-2

It's a tinyblob. Just got it working with Grails3.

Chris Malan
  • 127
  • 1
  • 8