简体   繁体   中英

How do I configure Hibernate to work in Karaf JPA Example?

I am wanting to understand this Karaf JPA example .

When I follow the instructions to add features and run the bundles for eclipseLink, the example works correctly.

However, if I try to use Hibernate, it doesn't work. I don't know Hibernate / H2 well enough to know what I am missing. When I run feature:install karaf-jpa-example-provider-ds-hibernate , I see this in the log:

javax.persistence.PersistenceException: [PersistenceUnit: booking-hibernate] Unable to build Hibernate SessionFactory

diag returns this information:

Status: Waiting
Declarative Services
org.apache.karaf.examples.jpa.provider.ds.hibernate.BookingServiceImpl (1) missing references: jpaTemplate

The karaf and H2 installs are new and empty. My suspicion is that there is something in H2 I need to do but I have no experience with this db.

Edit : Using the blueprint example, again eclipseLink works and Hibernate does not. Performing this command: feature:install karaf-jpa-example-provider-blueprint-hibernate causes this error in the log:

ERROR [features-2-thread-1] Bundle org.apache.aries.jpa.container [72] EventDispatcher: Error during dispatch. (javax.persistence.PersistenceException: [PersistenceUnit: booking-hibernate] Unable to build Hibernate SessionFactory)
javax.persistence.PersistenceException: [PersistenceUnit: booking-hibernate] Unable to build Hibernate SessionFactory

And this is the diag:

Missing dependencies:
(&(osgi.unit.name=booking-hibernate) 
(objectClass=javax.persistence.EntityManager))

Edit #2 : I am using JDK11 (11.0.2).

thanks, jon

It appears the problem is JDK11. I have moved to JDK8 and it is working.

This is the post that clued me in: https://hibernate.atlassian.net/browse/HHH-12924

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM