Any way to use JPA and JDO together easily?


As I am migrating my legacy Kodo based application to DataNucleus, I noticed that the application uses both JDO for most persistence based interaction, however has several JPQL queries which leverage a JPA Entity Manager.  The app leverages OpenJPA's  `JPAFacadeHelper.toEntityManager()` to create a JPA entity manager from Kodo's persistence manager.  My application exclusively uses a RDBMS store (MSSQL to be specific).

I've skimmed through the DataNucleus Javadocs and don't see anything similar; something to provide a JPA interface from a given JDO Persistence Manager.  Given that they are 2 completely different APIs, I'm not completely surprised, but was still hopeful that something might exist.

So the question becomes:
1) Does DN provide any kind of Facade/factory that allows me to create/generate a JPA Entity Manager from a JDO Persistence Manager?
2) Is there an easy way to use a DN JPA Entity Manager  with a JDO application?  Or is my only hope to identity all my persistence objects as `@Entity` and enhance them with the JPA enhancer?  I would rather stick with JDO definitions if possible (annotations and/or package.jdo)  as JPA/JPQL is only used for queries (not for updates or deletes).  Similarly, maintaining both an orm.xml and a package.jdo is going to be risky and problematic.

Converting all JPQL queries to JDO based queries is not an option at this time; I need to find a solution to use them both together.




Perhaps you would be better off looking at the DataNucleus (and JDO) documentation.

The JDO spec mandates being able to use JPA metadata (XML / annotations) with JDO persistence, and DataNucleus (JPA) also allows use of JDO metadata (XML / annotations) with JPA persistence.
DataNucleus seemingly allows use of JPQL with the JDO API (without the need to create any EntityManagerFactory), though not sure what query needs JPQL for that JDOQL can't express.

A query language like JPQL is in core code and hence available to both APIs.

Kodo doesn't seem to be as flexible as that ;-)


Thanks; I hadn't seen that extension.

I see that the the JDO pm allows for using JPQL but remaining within the JDO framework.  Which from a consistency perspective is great.  However, from a "retrofit" perspective, I still have the problem of my legacy code using all javax.persistence constructs and classes.  But hopefully shouldn't be too bad - I see many of the javax.jdo.Query methods are analogous to the javax.persistence.Query methods.

I will post as I continue the efforts if I have additional JPQL questions/issues.  So far, a quick test has yielded great results.