ObjectDB ObjectDB

Finding out the JPA provider


Do you have any preferred way of finding out whether ObjectDb is my EntityManager's JPA Provider?

I know there are problems with using getDelegate ( http://weblogs.java.net/blog/ss141213/archive/2009/05/be_careful_whil.html ) but on the other hand unwrap is not very portable ( https://forums.oracle.com/forums/thread.jspa?threadID=2149162 ). It would be nice if the <provider> element of the PeristenceUnit were visible in one of the Properties sets returned by the EntityManager and EntityManagerFactory, but its not.

So I am left with

    EntityManager.getDelegate() instanceof com.objectdb.jdo.PMImpl


    EntityManagerFactory instanceof com.objectdb.jpa.EMF.

Or putting something in my properties for this sole purpose...

    <property name="uk.co.his.jpa.provider" value="ObjectDb" />

At the momment I'll stick with the latter...


Your solution is fine, but you may also simply check for the "objectdb.home" property.

In the EntityManagerFactory:

    boolean isObjectDB = emf.getProperties().get("objectdb.home") != null;

Or in the EntityManager:

    boolean isObjectDB = em.getProperties().get("objectdb.home") != null;
ObjectDB Support


To post on this website please sign in.