Spring 4.3.0.RELEASE, Hibernate 5.0.9.Final, missing SessionFactoryImplementor.getProperties method - spring

I am using Spring 4.3.0.RELEASE together with Hibernate 5.0.9.Final in my app and I keep getting
java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Map;
If I update the Hibernate 5.2.0.Final, everything works fine. It seems that Spring 4.3.0 is not compatible with Hibernate 5.0, is that correct ? I was not able to find anything about not supporting Hibernate 5.0.
In Hibernate 5.2, such method exists, in Hibernate 5.0 the method doesn't exist yet (just replace 5.2 with 5.0 in URL):
http://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/engine/spi/SessionFactoryImplementor.html
I have created simple reproducer:
https://github.com/trepel/spring43-hibernate50-error
Thanks for all your replies.

There is already an issue, SPR-14365, covering that.

Related

Hibernate version compatibility with Spring 5.3.22

I would like to find out what is the compatible version of hibernate core and validator for spring version 5.3.22. I tried to search for the spring-orm 5.3.22 pom xml file in the .m2\repository\org\springframework\spring-orm, but it did not show any information related hibernate. I have tried using 5.3.22.RELEASE, but the result stays the same. Are there any approach that I can use to determine the compatible version? Thank you in advance.

Hibernate Search breaks with Spring Boot 2.3.0

When i migrated one of my Hibernate Search project from Spring Boot 2.2.7.RELEASE to 2.3.0.RELEASE, application started facing deadlock during the very startup.
I can not see any error in the logs either.
My sample project is here:
https://github.com/cancerian0684/listing-service
If i rollback Spring Boot 2.3.0 to 2.2.7, everything started working fine again. Is there a known issue in using Hibernate Search (tried both 5.x and 6.0.0.Beta8) with Spring Boot 2.3.0?
Spring Boot 2.3 switched to deferred JPA initialization and that leads to some issue, Hibernate Search being one of them. You should be able to get it back working using the following property
spring.data.jpa.repositories.bootstrap-mode=default
See this issue for some more context.

Hibernate-Search 6 and Elasticsearch integration

I am working ina Hibernate Search application and I am trying to use version 6 (which right now is in beta). I followed all the instructions and documentation in https://docs.jboss.org/hibernate/search/6.0/reference/en-US/html_single/#getting-started-configuration
After trying to start my application I get next error:
I have looked in Google and seems to be I am the first person in the world who is facing this issue.
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.hibernate.search.mapper.orm.mapping.impl.HibernateOrmIndexedTypeContext.<init>(HibernateOrmIndexedTypeContext.java:35)
The following method did not exist:
org.hibernate.metamodel.spi.MetamodelImplementor.entity(Ljava/lang/Class;)Lorg/hibernate/metamodel/model/domain/spi/EntityTypeDescriptor;
It was loaded from the following location:
file:/home/myUser/.m2/repository/org/hibernate/hibernate-core/5.3.11.Final/hibernate-core-5.3.11.Final.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.hibernate.metamodel.spi.MetamodelImplementor
Any idea of how to solve it?, In my application I am working with Spring boot and jpa.
As indicated here in the documentation, Hibernate Search 6.0.0.Beta2 requires Hibernate ORM 5.4.7.Final or later. You are using Hibernate ORM 5.3.11.Final.
I think Spring Boot 2.1 ships with ORM 5.3, so that's probably what you're using.
The best course of action would be to upgrade to Spring Boot 2.2.1.RELEASE, which ships with Hibernate ORM 5.4.
If that's not possible, you can still stay with Spring Boot 2.1 and override the version of Hibernate ORM directly in your POM: from what I've seen, it works rather well in Spring Boot 2.1.
Just set this property in your POM:
<properties>
<!-- Override the version of Hibernate ORM in Spring Boot -->
<hibernate.version>5.4.7.Final</hibernate.version>
</properties>
Note that technically, any version after Hibernate ORM 5.4.4.Final should work, but sticking to the version Hibernate Search was tested with is usually safer.

EHCache with Hibernate Integration Throwing CacheException

I am facing issue in integrating Hibernate And EHCache. I am using Hibernate 3.2.7 GA, Hibernate Annotation 3.2.1 ga,hibernate-commons-annotations 3.2.0.Final, net.sf.ehcache 2.2.0 and Spring version 3.2.4.RELEASE. When I ran my test case I am getting
net.sf.ehcache.CacheException: Error configuring from /content/cache/ehcache.xml. Initial cause was Error configuring from input stream. Initial cause was null:19: Element does not allow attribute "maxEntriesLocalHeap".
In Hibernate config file i have put
true
Please help me to solve the issue. I am new to EHCache.
Fairly confident the 2.2 version of Ehcache doesn't support that maxEntriesLocalHeap. Any reason you're using such an old version?
You either need to use a newer one, or modify your ehcache.xml to comply to the 2.2 XSD

JBOSS 5 and Spring 3 Validation Annotations

I have been trying to set up Spring 3 annotation-based validation, guided by http://static.springsource.org/spring/docs/3.0.0.RC3/spring-framework-reference/html/ch05s07.html. I am using JBOSS 5.0.1 server; however, upon invoking the #Valid annotation from the Controller. I received errors and found out it will require javax.validation.*;
Upon adding the validation-api-1.0.0.GA.jar (for javax.validation.*), I received complaints about it requiring Hibernate Validator 4+, which in turn requires Hibernate 3.5+. Finally, I discovered that JBOSS 5 does not support Hibernate 3.5+ because it uses JPA-2 and JBOSS 5 is tightly coupled to JPA-1.
At this point, my brain hurts.
Does anyone have a successful example of using Spring 3 annotation-based validation under JBOSS 5?
I finally figured out the answer to this. I basically reverted to using Hibernate Validator 3.1 using this example:
http://wheelersoftware.com/articles/hibernate-validator-3.html
Hope this helps anybody else.
I just wanted to add one more thing. I managed to wire Hibernate Validator 4.01 to JBOSS 5.01. The steps were as follows:
Remove hibernate-validator.jar from the JBOSS common/lib directory
Insert the validation-api-1.0.0.GA.jar, hibernate-validator-4.1.0.Final.jar into your project's WEB-INF/lib directory.

Resources