Hello, We are upgrading from a grails 6.2.3 projec...
# questions
u
Hello, We are upgrading from a grails 6.2.3 project to grails 7.0.10 and cant resolve an issue with what seems like incompatible dependencies and so we're hoping we can get some guidance for resolving this. We are using hibernate-envers which in grails 7 uses hibernate 6, but also gorm for hibernate 5, which of course uses hibernate 5. We are getting exceptions because classes that implement interface org.hibernate.usertype.UserType do not have the implemented methods. Between hibernate 5 and 6 the methods in this class that should be implemented have changed. In particular changing from
int[] sqlTypes()
to
int getSqlType()
and similarly the signature (in particular the parameters) of the
nullSafeGet
method has changed. In grails 6 we had the following in our build.gradle, which if I understand correctly, allowed us to use envers with the version of hibernate-core that was in gorm for hibernate 5 that we we were using. But this no longer works now that there are breaking changes between the versions used in each case.
Copy code
api ("org.hibernate:hibernate-envers") {
        exclude module: 'hibernate-core'
        exclude module: 'hibernate-entitymanager'
    }
Below is an excerpt from a stack trace where it seems to be resolving to the hibernate 5 version of UserType when the hibernate 6 version is expected. Is there anything we can do about this? Or what steps can we take to figure out a solution for this?
Copy code
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:223)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:146)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:318)
        ... 106 common frames omitted
Caused by: java.lang.AbstractMethodError: Receiver class org.hibernate.envers.internal.entities.RevisionTypeType does not define or inherit an implementation of the resolved method 'abstract int[] sqlTypes()' of interface org.hibernate.usertype.UserType
j
Why are you using the hibernate 6 version fo envers? Is it just b/c the bom is suggesting that?
u
yes and because I'm pretty sure the hibernate 5 version uses javax libraries. But I'll double check that. Sorry I've been trying so many things working on this upgrade I may be confused with what is what.
j
the reason i ask is historically we were inheritting the spring bom, and we only tested with the libraries we use. so its possible we should be excluding that version and pinning it for you
u
Well.... in double checking based on your first question, I just realized that there is a jakarta variant for the hibernate 5 version of envers. So I think I should try with that and see what happens.
👍 1
j
yes, that is usually the solution
u
It worked! Thanks so much. Appreciate your help. Now I just have another issue preventing the app from starting up that I need to look into.