We are using hibernate validator version 5.2.5.Final with spring version 5.0.15RELEASE to validate the input data along with bean-io framework.
Now we are planning to upgrade the hibernate validator to latest version 6.1.5 to improve the performance of the workflow.
Kindly provide the compatible version of spring framework version with latest hibernate validator.
The following part of the documentation will give you a hint.
As of Spring 5.0, this class requires Bean Validation 1.1+, with special support for Hibernate Validator 5.x (see setValidationMessageSource(org.springframework.context.MessageSource)). This class is also runtime-compatible with Bean Validation 2.0 and Hibernate Validator 6.0, with one special note: If you'd like to call BV 2.0's getClockProvider() method, obtain the native ValidatorFactory through #unwrap(ValidatorFactory.class) and call the getClockProvider() method on the returned native reference there.
Related
I am migrating 3.2.X to 4.1.10 version of spring data Elasticsearch but SearchResultMapper class is not available to use. I have searched this in documentation of spring also but no luck for alternative class.
I am using JPA 2.1 in my project (Hibernate 5.x) and deploying in IBM WAS 8.5.5.
Since IBM WAS 8.5.5 supports only JPA 2.0 by the container, There is persistence loader issue during application deployment.
Is it possible to configure custom JPA at app level in WAS.
I already tried - IBM WAS Documentation
You said you tried https://developer.ibm.com/wasdev/docs/can-i-use-jpa-2-1-on-websphere-application-server/, but what part of this document is not working? This is the page I would reference if you are trying to get JPA 2.1 running on 8.5.5.
Some alternate suggestions:
Traditional WebSphere v9 supports the JPA 2.1 specification level. I would recommend using WebSphere v9 for your project instead of 8.5.5 if you really need to use Hibernate 5.x
Hibernate 4.2 was the last version that supports JPA 2.0. You can downgrade to this version of Hibernate if you dont have to use JPA 2.1
Either of these solutions gain you container support and will provide the JPA API bundle for you. Whichever you go with, make sure not to bundle your Hibernate JPA persistence API bundles in your application. Hibernate repackages its API into "hibernate-jpa-2.x-api.Final.jar". I have seen this before as a conflict that customers build into their applications.
With class loading strategy, I was able to override the JPA 2.0 of container.
using the inputs from IBM Developers support.
I am aware of the following answer:
Hibernate 5.0.11 - AttributeConverter class registered mulitple times
But it isn't solving my problem. I'm upgrading Spring Boot from 1.5.4 to 2.0.4 and I'm getting
AttributeConverter class [class com.foo.CalculationModeConverter] registered multiple times
None of the code around converters has changed during the upgrade. Hibernate is registered at org.hibernate:hibernate-core:5.2.17.Final according to the dependencies task.
All of my converters were annotated with #Converter and entities used #Convert on properties. This seems to now cause a double registration. I removed #Converter and all is well thus far. I still want to find the documentation on when this changed.
I'm a little confused about SpringBoot's (1.3.0) support of Hibernate5. The reference lists a dependency on hibernate 4.3.11.Final but it also lists a dependency on SpringFramework 4.2.3 which includes Hibernate5 support.
Is it just a matter of adding the extra Hibernate5 dependencies to override what Boot bundles? Can someone please clarify for me?
You can use either Hibernate 4.3 or Hibernate 5.0 with Spring Boot 1.3. As you've observed, Hibernate 4.3.x is the default version.
To use Hibernate 5.0 you should override the hibernate.version property in Spring Boot's dependency management. Assuming that you're using Maven:
<properties>
<hibernate.version>5.0.5.Final</hibernate.version>
</properties>
When using Hibernate 5.0, the one big difference from using Hibernate 4.3.x is that you'll lose Spring Boot's custom naming strategy. Due to a breaking change made in Hibernate 5.0, you'll see a warning like this logged at startup:
2015-12-07 10:04:56.911 WARN 81371 --- [ main] org.hibernate.orm.deprecation : HHH90000006: Attempted to specify unsupported NamingStrategy via setting [hibernate.ejb.naming_strategy]; NamingStrategy has been removed in favor of the split ImplicitNamingStrategy and PhysicalNamingStrategy; use [hibernate.implicit_naming_strategy] or [hibernate.physical_naming_strategy], respectively, instead.
If you dislike Hibernate 5's defaults, you can specify a custom implicit or physical naming strategy in Spring Boot's application.properties using the spring.jpa.properties.hibernate.implicit_naming_strategy and spring.jpa.properties.hibernate.physical_naming_strategy properties respectively.
Update July 2016: With the release of Spring Boot 1.4.0 the default Hibernate 5 is used as the default JPA persistence provider.
There is a ticket about migrating to Hibernate 5 for some time now - it seems the main setback is some name strategy incompatibility. Asof now, the ticket is currently scheduled for 1.4.0
Thanks guys! after many trials, this solution worked for me like a charm! I implemented custom strategy and set them in application.yml as shown below:
jpa:
database: MYSQL
database-platform: org.hibernate.dialect.MySQL5Dialect
properties:
hibernate:
implicit_naming_strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
physical_naming_strategy: com.quicken.ups.entities.utils.DBFieldNamingStrategy
Is it safe to use the Hibernate Validator 5.0.1 with Hibernate 3.5.4? From what I've read it should not be a problem and I'm not running into any errors so far (i.e. application compiles, runs and tests pass), but I'm not sure if they fit well together.
Related Hibernate & JPA libs (inside /WEB-INF/libs):
hibernate3.jar
hibernate-annotations-3.5.4-Final.jar
hibernate-commons-annotations-3.2.0.Final.jar
hibernate-core-3.5.4-Final.jar
hibernate-entitymanager-3.5.4-Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate-validator-5.0.1.Final.jar
hibernate-validator-annotation-processor-5.0.1.Final.jar
validation-api-1.1.0.Final.jar
FYI:
Tomcat 7.0.39
Spring 3.0.3
PostgreSQL 9.2
Flyway 2.1.1
BoneCP 0.7.1
You should be fine with using Bean Validation 1.1/Hibernate Validator 5.0.1; Hibernate ORM depends on the Bean Validation API only, and BV 1.1 is compatible with BV 1.0.
I recommend to check the Hibernate Validator migration guide to see whether any of the issues listed there might affect you (for instances changes around logging and the usage of Java 6).