Hibernate 7 and NoClassDefFoundError on BindableType

Hi,

I make some tests with Hibernate 7 and I have a NoClassDefFoundError: NoClassDefFoundError: org/hibernate/query/BindableType

On migration guide (7.0 Migration Guide) , I found :
Incubating interfaces BindableType, OutputableType, and BindingContext were moved to org.hibernate.type

But I can’t find org.hibernate.type

Regards

Not sure what the problem is on your end, but here you can see the file being there in the Git repository: hibernate-orm/hibernate-core/src/main/java/org/hibernate/type/BindableType.java at 7.0 · hibernate/hibernate-orm · GitHub

Maybe clear your local caches?

have similar issue when i call @Query native, the difference in package : org.hibernate.query.BindableType but in git package is org.hibernate.type.BindableType
org.hibernate.query
org.hibernate.type

I don’t know what this @Query annotation does, but maybe you compiled against an old version of Hibernate ORM?

I also have this issue and in my case it’s likely caused by using spring-data-jpa version 3.5.4:

java.lang.NoClassDefFoundError: org/hibernate/query/BindableType
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.obtainParameterAccessor(AbstractJpaQuery.java:170)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:159)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:148)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:170)\

which seems to have Hibernate 6 as a dependency it tries to pull in.

If you’re using spring-data-jpa, I suspect an upgrade to any version 4 will do the trick?

Good morning,

I verified that after replacing Hibernate 7.1.4.Final on the 3.5X branch,
the only compilation issue is an assertion. Basically, the problematic class

org.springframework.data.jpa.repository.query.HibernateJpaParametersParameterAccessor

doesn’t contain any references to org/hibernate/query/BindableType at the source level,
but it fails at runtime. Looking at the disassembled code, I found this:

L6 {
    f_new (Locals[4]: org/springframework/data/jpa/repository/query/HibernateJpaParametersParameterAccessor, org/springframework/data/repository/query/Parameter, java/lang/Object, org/hibernate/type/BasicType) (Stack[0]) 
    new org/hibernate/query/TypedParameterValue
    dup
    aload 3
    aconst_null
    invokespecial org/hibernate/query/TypedParameterValue.<init>(Lorg/hibernate/query/BindableType;Ljava/lang/Object;)V
    areturn
}

When compiled, Java resolves the type and silently causes the issue.
As a workaround, while waiting for the final release of Spring Data JPA 4.0 natively supporting Hibernate 7,
I imported a local copy of HibernateJpaParametersParameterAccessor, which, when compiled against Hibernate 7,
correctly resolves the type.

Other than that, I haven’t encountered any problems — and I’ve tested it with dozens of jpql queries.

The first native query I had to write caused the problem, which I resolved as described above.