1

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)?

matthjes
  • 671
  • 7
  • 20

2 Answers2

0

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)

Clement
  • 2,817
  • 1
  • 12
  • 11
  • Would you suggest using both iPOJO and Aries? I was thinking about using Aries for bundles that offer database related services and iPOJO for the rest, however, I have to test this. – matthjes Nov 29 '14 at 11:07
0

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.

matthjes
  • 671
  • 7
  • 20