How can I get all @Entity classes from a Persistence Unit?
Problem I'm writing a standalone utility program which, given a jar containing a JPA-2 annotated persistence unit, needs to programmatically get a list of all my @Entity classes in a particular persistence unit. I'd like to decide which of 2 approaches would be the way to go to get this information, and why; or if there is another better way I haven't thought of. Solution 1 Java program puts jar on the classpath, creates persistence unit from the classes in the jar using JavaSE methodologies. Then it uses the javax.persistence classes to get the JPA Metamodel, pull back list of class tokens