spring4.2.1, hibernate5 integrate abstract method error

懵懂的女人 提交于 2019-11-30 19:04:20

This is an issue with Jadira Usertype 4.0.0.GA and earlier, in combination with Hibernate 5. It is fixed in Usertype 5.0.0.GA (see http://jadira.sourceforge.net/changes-report.html#a5.0.0.GA).

In my case, I was using Usertype 3.0.0.CR3 for JodaTime support. I wasn't attempting to use Java 8 (JSR-310) time classes or org.jadira.usertype:usertype.extended.

Debugging shows that the exception occurs while trying to add an integrator of type "org.jadira.usertype.dateandtime.joda.integrator.UserTypeJodaTimeHibernateIntegrator" to the integratorObservers of hibernate's SessionFactoryImpl.

If using JSR-310, then as martian suggests use the hibernate-java8 module. If using JodaTime and not JSR-310 times, then this won't help. A relatively simple workaround is to create a JPA 2.1 AttributeConverter for each JodaTime type that you use.

AttributeConverters can also be used for JSR-310 types. They have the advantage of being portable and that you don't have to annotate each entity field, if you set autoApply=true.

Example classes:

https://github.com/marschall/threeten-jpa/tree/master/threeten-jpa/src/main/java/com/github/marschall/threeten/jpa

It seems usertype is to blame, usertype 4.0.0.GA does not support hibernate5, for hibernate5 has its own implements of java 8 classes. remove org.jadira.usertype:usertype.extend and add org.hibernate:hibernate-java8, the problem will be gone.

I got the same issue resolved by using below usertype

    <dependency>
        <groupId>org.jadira.usertype</groupId>
        <artifactId>usertype.core</artifactId>
        <version>5.0.0.GA</version>
    </dependency>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!