persistence@glassfish.java.net

RE: List of entity classes

From: Douglas Clarke <DOUGLAS.CLARKE_at_oracle.com>
Date: Thu, 25 Feb 2010 04:24:22 -0800 (PST)

If you are using the latest JPA 2.0 version of EclipseLink you can use:

EntityManagerFactory.getMetamodel();

Doug
  -----Original Message-----
  From: Gary Jacobson [mailto:gtjacobson_at_gmail.com]
  Sent: February 25, 2010 7:00 AM
  To: persistence_at_glassfish.dev.java.net
  Subject: List of entity classes


  Hi all

  Is there any way to retrieve a list of the entity classes available in the application? (i.e. any class with @Entity annotated)

  The only way I can think to do this is to use native SQL to get a list of all database table names, convert them to class names by using my naming convention, and loading each class via reflection.

  I would guess that there must be some internal toplink utility class which maintains a list.

  Thanks
  Gary