Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes Find @Entity classes in current project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Find @Entity classes in current project" Watch "Find @Entity classes in current project" New topic
Author

Find @Entity classes in current project

Mahesh Kedari
Ranch Hand

Joined: Nov 28, 2009
Posts: 111
Hi,
Is there any way to get a list of all classes with @Entity annotation in current project?
I am using Netbeans IDE. In netbeans when i open persistence.xml in design mode, and click on Add Class button, i get a list of all classes in current project with @Entity annotation.
I wanted to get a similar list to manually configure Hibernate. Can anyone help me for this?

Thank you
Mahesh Kedari
Leandro Coutinho
Ranch Hand

Joined: Mar 04, 2009
Posts: 417
If Netbeans does it, then you already have the list. And if your project is corrected structured, then all entities are in the model package.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

At runtime you can ask the provider all the entity classes for a given persistence-unit by invoking:


I do believe that this is JPA 2.0 only. Not sure.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
 
 
subject: Find @Entity classes in current project
 
Similar Threads
EJB3 JPA entities OntoMAny two jar
modeling JSF managed beans on component diagram
Define external lib classes as entities in a different module/project
How to get all entities in a list ?
How to map .hbm.xml file in persistence.xml