I'm trying to migrate from EclipseLink to Hibernate in my Java EE 7 application and running into some issues I'm not able to figure out.
Here my environment:
- Glassfish 4.1
- Hibernate 4.3.6
- Java 1.8.0_20
I'm also using:
- EE 7
- CDI
- JPA 2.1
Ultimately our goal is to be able to use Java 8 Streams and Lambdas, as our app has a lot of set manipulation, and EclipseLink currently doesn't support Streams. We have another project running with Hibernate (on Wildfly) that does this, but was hoping we could just migrate to Hibernate instead of swapping the whole Java EE App Server Stack.
So far here's what I've done, but mostly followed the guidance here: https://coderwall.com/p/e5fxrw
I've installed the required and entity-manager Hibernate jars into my /glassfish/lib directory.
I've modified my persistence-unit in persistence.xml as follows:
<persistence-unit name="mypu" transaction-type="JTA"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <jta-data-source>jdbc/myds</jta-data-source> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.transaction.jta.platform" value="org.hibernate.engine.transaction.jta.platform.internal.SunOneJtaPlatform" /> <property name="hibernate.transaction.factory_class" value="org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory"/> <property name="hibernate.hbm2ddl.auto" value="update"/> </properties> </persistence-unit>
Now the first exception I get is is "java.lang.IllegalArgumentException: Not an entity: ..." However my classes are all annotated with @Entity, and were working under EclipseLink. I don't think I should have to list my classes with the exclude-unlisted-classes = false and really would like to avoid that.
edit: Per unwichtich's suggestion, I've tried adding:
<property name="hibernate.archive.autodetection" value="class, hbm"/>
and individually specifying the classes in the PU within the persistence.xml with no improvement.
Thanks for any assistance.