Re: List of entity classes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: List of entity classes

Gary Jacobson
Thanks Doug

Unfortunately I am stuck with Toplink Essentials 2.0... do you know of any equivalent class/method I could use?

---------- Forwarded message ----------
From: Douglas Clarke <[hidden email]>
To: [hidden email]
Date: Thu, 25 Feb 2010 04:24:22 -0800 (PST)
Subject: RE: List of entity classes
If you are using the latest JPA 2.0 version of EclipseLink you can use:
 
EntityManagerFactory.getMetamodel();
 
Doug
-----Original Message-----
From: Gary Jacobson [mailto:[hidden email]]
Sent: February 25, 2010 7:00 AM
To: [hidden email]
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


Reply | Threaded
Open this post in threaded view
|

RE: List of entity classes

djclarke
Gary,
 
TopLink Essentials has its own native metamodel you can use as well. Do you have access to an EntityManagerFactory in your usage or just managed EntityManager instances?
 
Doug
-----Original Message-----
From: Gary Jacobson [mailto:[hidden email]]
Sent: March 1, 2010 3:52 AM
To: [hidden email]
Subject: Re: List of entity classes

Thanks Doug

Unfortunately I am stuck with Toplink Essentials 2.0... do you know of any equivalent class/method I could use?

---------- Forwarded message ----------
From: Douglas Clarke <[hidden email]>
To: [hidden email]
Date: Thu, 25 Feb 2010 04:24:22 -0800 (PST)
Subject: RE: List of entity classes
If you are using the latest JPA 2.0 version of EclipseLink you can use:
 
EntityManagerFactory.getMetamodel();
 
Doug
-----Original Message-----
From: Gary Jacobson [mailto:[hidden email]]
Sent: February 25, 2010 7:00 AM
To: [hidden email]
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