How to use JPA (Hibernate) with Apache iPOJO

204 Views Asked by At

Does anyony have an example how to use JPA (Hibernate) with iPOJO?

What is the usual way how OSGi bundles (using iPOJO) interact with databases. For example, is the EntityManagerFactory provided as a service? Or is there a single service that is responsible for working with the database (and this service create an EntityManager using the factory)?

2

There are 2 best solutions below

1
On

It's not related to iPOJO, it's more about how to use JPA in OSGi. Apache Aries has done a nice set of bundles to support JPA (http://aries.apache.org/modules/jpaproject.html). Wisdom Framework (http://wisdom-framework.org) also supports JPA (OpenJPA) (https://github.com/wisdom-framework/wisdom-jdbc/tree/master/openjpa-sample)

0
On

While it seems like that it is currently not possible to inject an EntityManager into an iPOJO component, one can combine Aries blueprint and iPOJO to provide database-related services to iPOJO components.

The solution is to create bundles for the data source and database-related services (which use DAOs, which in turn use an EntityManager) using Aries blueprint and then inject those services into an iPOJO component with @Requires.