Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring get all @Entity classes

Tags:

spring

entity

Is there a way to get all @Entity classes in Spring? I can't seem to find any solution. Thanks.

answer:

<dependency>
   <groupId>org.reflections</groupId>
   <artifactId>reflections</artifactId>
   <version>0.9.5</version>
</dependency>

will do this easily ;)

like image 978
Marius Avatar asked Sep 07 '11 09:09

Marius


1 Answers

Why do you need this? I suppose you are in a JPA context, then you can do it like this:

entityManager.getMetamodel().getEntities();
like image 51
sinuhepop Avatar answered Oct 13 '22 23:10

sinuhepop