Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Find @Entity classes in current project

 
Mahesh Kedari
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic