Reputation: 353
I want to downgrade JPA versions and use JPA 2.0. Spring Boot's Data JPA starter comes with Hibernate 4.3 which supports JPA 2.1. According to the docs, I should be able to do this in my build.gradle:
'org.hibernate:hibernate-entitymanager:4.2.16.Final'
However Hibernate 4.3 is still being used. And there is no way of changing the javax.persistence:hibernate-jpa dependency to
'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
Is this possible?
Upvotes: 0
Views: 5542
Reputation: 1
I using Spring boot version 1.5.8.RELEASE, and i downgraded java version of hibernate core using
<properties>
<finalName>${project.artifactId}</finalName>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<hibernate.version>4.2.21.Final</hibernate.version>
</properties>
Upvotes: 0
Reputation: 353
Seems I misinterpreted the Spring Boot guide. For anyone wanting to know the answer, it isn't as simple as Maven to just declare a version in the properties. But after looking into Gradle's docs on how replace dependencies, I came across this section: Substituting a dependency module with a compatible replacement
So essentially all I need to do is this:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
// Use Hibernate 4.2
if (details.requested.name == "hibernate-entitymanager") {
details.useTarget "org.hibernate:hibernate-entitymanager:4.2.16.Final"
}
// Use JPA 2.0
if (details.requested.name == "hibernate-jpa-2.1-api") {
details.useTarget "org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final"
}
}
}
And voila!
Upvotes: 2