Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Using JPA without publishing the persistence unit with Gemini JPA
Using JPA without publishing the persistence unit with Gemini JPA [message #1033868] Thu, 04 April 2013 18:36 Go to next message
Jochen Seeber is currently offline Jochen SeeberFriend
Messages: 1
Registered: April 2013
Junior Member
Hi,

I am trying to create a "private" persistence unit in my bundle that I do not want published as a service. For this reason, I'm not using the "Meta-Persistence" element in my manifest, but trying to create the EntityManager the non-OSGi way:

EntityManager em = Persistence.createEntityManagerFactory("unit").createEntityManager();

However, since OSGi's JPA replaces the PersistenceProvider(Resolver) and only does a service lookup, the creation of the EntityManagerFactory fails.

My question now is: What is the right way in Gemini JPA to create a "private" EntityManagerFactory that is not exposed to other bundles, and use it in the bundle?

If this is not possible, how can I create an EntityManagerFactory using "Meta-Persistence" and use it in the same module (since the EMF is only registered by Gemini after the bundle was started).

Regards,
Jochen

[Updated on: Sat, 06 April 2013 17:50]

Report message to a moderator

Re: Using JPA without publishing the persistence unit with Gemini JPA [message #1036798 is a reply to message #1033868] Mon, 08 April 2013 20:43 Go to previous message
Michael Keith is currently offline Michael KeithFriend
Messages: 243
Registered: July 2009
Senior Member
Hi Jochen,

Do you not want the EMF service in the registry simply because you don't want someone to stumble into it, or because you want it completely isolated from all other bundles so that it would be impossible for them to use it.

In the first case you could just remove the DB connection info from the persistence descriptor. This will cause the EMFBuilder to be registered, but not the EMF. Then you could pass the DB props into the Persistence.createEntityManagerFactory() call and it will look for the builder instead of an EMF service and use it to create an EMF for you.

The second case is a bigger issue. Applications that want strict isolation typically use service permissions with an active security manager. Take a look at service permissions as well as the Permission Admin service.

-Mike
Previous Topic:Maven repository for Gemini projects
Next Topic:[Solved]Handling subclasses of Entities (Cross Bundle Workaround)
Goto Forum:
  


Current Time: Fri Oct 04 09:06:20 GMT 2024

Powered by FUDForum. Page generated in 0.03190 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top