I have three persistence-unit nodes in my persistence.xml: one for Toplink with the toplink provider specified, one for Hibernate, and one for OpenJPA.

It tests various operations in JPA, configured to use whichever JPA supplier I specify at the time, i.e. I just change the name of the persistence-unit I pass to Persistence.createEntityManagerFactory().

So I have, for instance at the moment, not only openjpa.jar on the classpath, but also hibernate-entitymanager.jar and toplink-essentials.jar.

When running my test, due to the way javax.persistence.Persistence.class is programmed, any of those providers may be picked for use, without reference to the name of the persistence-unit name that I specified when calling createEntityManagerFactory() - somewhat surprisingly!

If my memory serves me well, the persistence-api.jar that I am using is just the one that maven downloaded automatically from the global jar repo.

I'm tempted to create my own javax.persistence.Persistence to do it properly and position it ahead of the persistence-api.jar on my classpath.

This just doesn't seem right. I guess I should be asking at Sun. Was it Sun who wrote javax.persistence.Persistence ? Or are there different versions? Is there an 'OpenJPA persistence-api'?

Has anyone here written their own and made it publicly available?


Thanks
Adam

Reply via email to