Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo/Hibernate] "javax.persistence" and bundles from elver.org update site(Both "org.hibernate" and "javax.persistence" includes a JPA definition)
[Teneo/Hibernate] "javax.persistence" and bundles from elver.org update site [message #638926] |
Sat, 13 November 2010 11:09 |
Alex Mising name Messages: 149 Registered: March 2010 |
Senior Member |
|
|
Hi,
I'm trying to setup a Teneo/Hibernate project and enable use of JPA for the data store (instead of the Hibernate session API).
My problem is however, that the "org.hibernate" bundle from "elver.org" includes the "hibernate-jpa-2.0-api-1.0.0.Final.jar" via its runtime classpath, but does NOT export it. Therefore, to use JPA in my own code, I have to add a dependency to the "javax.persistence" (again from the "elver.org" update site) bundle, but this results in two separate definitions of JPA being in use.
As a result, the following method I have defined in my bundle (which depneds on both "javax.persistence" and "org.hibernate") tries to provide access to the EntityManagerFactory as defined by "javax.persitence" the bundle but ends up trying to return an object that implements EntityManagerFactory as defined by the "org.hibernate" bundle:
protected EntityManagerFactory getEntityManagerFactory() {
//...
HbEntityDataStore dataStore = new HbEntityDataStore();
// ...
dataStore.initialize();
// ...
return dataStore.getEntityManagerFactory();
}
This gives the linkage error below whyle trying to initialize the HbEntityDataStore (dataStore.initialize()).
java.lang.LinkageError: loader constraint violation: when resolving method "org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory()Ljavax/persistence/EntityManagerFactory;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, org/eclipse/emf/teneo/hibernate/HbEntityDataStore, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for resolved class, org/hibernate/ejb/Ejb3Configuration, have different Class objects for the type javax/persistence/EntityManagerFactory used in the signature
at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.buildEntityManagerFactory(HbEntityDataStore.java:242)
at org.eclipse.emf.teneo.hibernate.HbEntityDataStore.initialize(HbEntityDataStore.java:116)
So my question is, can one use JPA to access a data store, or is one not supposed to do that? If yes, is that possible with the bundles provided by elver.org as a convenience, or do I have to create my own "org.hibernate" (one the would depend on "javax.persistence" for the JPA definition)?
|
|
|
Re: [Teneo/Hibernate] "javax.persistence" and bundles from elver.org update site [message #638966 is a reply to message #638926] |
Sun, 14 November 2010 04:52 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Alex,
Ha, this was a mistake in the hibernate plugin. I have updated to the latest hibernate version yesterday so that's when
this error got introduced.
I have made new plugins available on the elver.org website which solve this issue. The hibernate plugin now does not
contain the javax.persistence jar anymore, it requires this to be provided by a separate plugin.
Let me know if it works fine for you now (or not ofcourse...).
btw, support for Teneo is given on the main EMF newsgroup which I added as cc.
gr. Martin
On 11/13/2010 12:09 PM, Alex wrote:
> Hi,
>
> I'm trying to setup a Teneo/Hibernate project and enable use of JPA for
> the data store (instead of the Hibernate session API).
>
> My problem is however, that the "org.hibernate" bundle from "elver.org"
> includes the "hibernate-jpa-2.0-api-1.0.0.Final.jar" via its runtime
> classpath, but does NOT export it. Therefore, to use JPA in my own code,
> I have to add a dependency to the "javax.persistence" (again from the
> "elver.org" update site) bundle, but this results in two separate
> definitions of JPA being in use.
>
> As a result, the following method I have defined in my bundle (which
> depneds on both "javax.persistence" and "org.hibernate") tries to
> provide access to the EntityManagerFactory as defined by
> "javax.persitence" the bundle but ends up trying to return an object
> that implements EntityManagerFactory as defined by the "org.hibernate"
> bundle:
>
> protected EntityManagerFactory getEntityManagerFactory() {
> //...
> HbEntityDataStore dataStore = new HbEntityDataStore();
> // ...
> dataStore.initialize();
> // ...
> return dataStore.getEntityManagerFactory();
> }
>
> This gives the linkage error below whyle trying to initialize the
> HbEntityDataStore (dataStore.initialize()).
> java.lang.LinkageError: loader constraint violation: when resolving
> method
> " org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactor y()Ljavax/persistence/EntityManagerFactory; "
> the class loader (instance of
> org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current
> class, org/eclipse/emf/teneo/hibernate/HbEntityDataStore, and the class
> loader (instance of
> org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for resolved
> class, org/hibernate/ejb/Ejb3Configuration, have different Class objects
> for the type javax/persistence/EntityManagerFactory used in the signature
> at
> org.eclipse.emf.teneo.hibernate.HbEntityDataStore.buildEntit yManagerFactory(HbEntityDataStore.java:242)
>
> at
> org.eclipse.emf.teneo.hibernate.HbEntityDataStore.initialize (HbEntityDataStore.java:116)
>
>
> So my question is, can one use JPA to access a data store, or is one not
> supposed to do that? If yes, is that possible with the bundles provided
> by elver.org as a convenience, or do I have to create my own
> "org.hibernate" (one the would depend on "javax.persistence" for the JPA
> definition)?
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Fri Apr 19 14:37:01 GMT 2024
Powered by FUDForum. Page generated in 0.01902 seconds
|