Remove deprecated PersistenceProvider from hibernate-entitymanager META-INF/services/javax.persistence.spi.PersistenceProvider

Description

I'm using hibernate 4.3.5.Final (using maven dependencies, and using Tomcat 7.0.47).

Like https://hibernate.atlassian.net/browse/HHH-8625#icft=HHH-8625 I'm using the correct provider in my META-INF/persistence.xml :

<persistence-unit name="com.iorga.irajblank" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> ...

But I'm getting

avr. 24, 2014 5:01:24 PM org.hibernate.ejb.HibernatePersistence logDeprecation WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.

I've seen that hibernate-entitymanager-4.3.5.Final.jar/META-INF/services/javax.persistence.spi.PersistenceProvider contains those lines :

org.hibernate.jpa.HibernatePersistenceProvider # The deprecated provider, logs warnings when used. org.hibernate.ejb.HibernatePersistence

But as in hibernate-jpa-2.1-api-1.0.0.Final.jar:javax.persistence.spi.PersistenceProviderResolverHolder.PersistenceProviderResolverPerClassLoader.CachingPersistenceProviderResolver.loadResolverClasses(ClassLoader) those ones are added in a HashSet (using addAll method), when listing them (in hibernate-jpa-2.1-api-1.0.0.Final.jar:javax.persistence.Persistence.getProviders()), org.hibernate.ejb.HibernatePersistence is listed first.

Activity

Steve EbersoleMarch 10, 2015 at 3:46 PM

Well, I would not say "all we need". Moving forward I think removing the old entry from META-INF/services/javax.persistence.spi.PersistenceProvider is clearly the right thing to do, for the reasons I outlined above.

Sanne GrinoveroMarch 10, 2015 at 3:43 PM

+1 for https://hibernate.atlassian.net/browse/JPA-67#icft=JPA-67 : all we need is enforce the right order

Steve EbersoleMarch 10, 2015 at 2:02 AM

Steve EbersoleMarch 9, 2015 at 7:53 PM

Discussed this in detail with Scott on IRC. Like I said, I had initially tried to remove org.hibernate.ejb.HibernatePersistence from Hibernate's META-INF/services/javax.persistence.spi.PersistenceProvider. That way, the only way it can be used as the provider is deployments which explicitly list that as the provider class : <provider>org.hibernate.ejb.HibernatePersistence</provider>, in which case the user is CLEARLY specifying the deprecated provider and should be warned.

META-INF/services/javax.persistence.spi.PersistenceProvider is all about dynamic discovery of providers and resolution of the provider to use in cases where the user did not specify which provider to use. In that case, there is no need for org.hibernate.ejb.HibernatePersistence to be listed in the service file.

When I originally tried to remove this from the Hibernate service file, it caused problems on WildFly. But in discussing this with Scott, I believe this is actually a problem in WildFly. So, for 5.0 (at least) I plan on removing org.hibernate.ejb.HibernatePersistence from the service file as the real solution to this.

We'll have to discuss a proper solution to this for 4.x. I don't think removing the entry is viable option there. Quite possibly the "solution" for 4.x is to wait for 5.0...

Steve EbersoleMarch 9, 2015 at 6:24 PM

- Does WildFly actually check that the named provider is "available" itself, rather than delegating the calls to the actual PersistenceProviders loaded? IIRC the issue in WildFLy was related to that. Again, Hibernate's org.hibernate.jpa.HibernatePersistenceProvider knows to accept <provider>org.hibernate.ejb.HibernatePersistence</provider>. The only time I can see org.hibernate.ejb.HibernatePersistence not being listed as a provider via META-INF/services/javax.persistence.spi.PersistenceProvider is if the environment (WildFly/Jipijapa) forces that issue.

Fixed

Details

Assignee

Reporter

Time tracking

0.02h logged

Fix versions

Affects versions

Priority

Created April 24, 2014 at 3:17 PM
Updated April 30, 2015 at 3:29 AM
Resolved March 11, 2015 at 1:49 AM

Flag notifications