JadiraOrg / jadira

Jadira Framework
Apache License 2.0
74 stars 44 forks source link

DateTime Column with @Version attribute #101

Open mea-alexanm opened 3 years ago

mea-alexanm commented 3 years ago

Hello, we have an application where we use optimisting locking like this:

@TypeDefs({ @TypeDef(name = "dateTime", defaultForType = org.joda.time.DateTime.class, typeClass = org.jadira.usertype.dateandtime.joda.PersistentDateTime.class) }) @Column(name = "LAST_UPDATE") @Version private DateTime lastUpdate;

This worked perfectly fine until we recently upgraded our application to newer version - including jadira to 7.0.0.CR1. Since then we get a class cast exception for above definition: java.lang.ClassCastException: class org.jadira.usertype.dateandtime.joda.PersistentDateTime cannot be cast to class org.hibernate.usertype.UserVersionType

Having a look at the source code of jadira it seems there was a change in the class hierarchy for PersistentDateTime class from AbstractVersionableUserType to AbstractParameterizedTemporalUserType which causes this error. At least with our versions.

The versions used are:

Any ideas how to solve this? For now we are trying to go back to version 6.0.1.GA of Jadira.

Thx Markus

froque commented 3 years ago

as I mentioned in #98 this project is practically dead.

I removed jadira from my project and I suggest you do the same.

Can not help with your problem.

rcbandit111 commented 2 years ago

@froque Can you share how to replace Jadira? Other framework that can be used with Hibernate?

froque commented 2 years ago

Replaced joda and jadira with Java 8 Instant.

Example:

        @NotNull
        @Column(name="activation_date")
-       @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
-       private DateTime activationDate;
+       private Instant activationDate;