August 22, 2012

Create a JPA EntityManager programmatically

I've been using this kind of PersistenceUnit creation for some unit tests, because they had to run along with some integration tests, and because of that the persistence.xml files were messing between them.

So, how to create an EntityManager programmatically?

  • Solution link: http://docs.jboss.org/hibernate/stable/entitymanager/reference/en/html/configuration.html