In a Spring Data JPA environment, you may want to retrieve the domain type of the repositories defined in your application. This tutorial will show two ways to retrieve Spring JPA repository domain type.

The two following solutions require Spring data commons. Make sure you have it in classpath.

Using Repositories

Spring data commons provides the class Repositories to handle JPA repositories. You can use it to retrieve the domain type of each repository as below :

Using DefaultRepositoryMetadata 

Spring data commons provides also DefaultRepositoryMetadata to retrieve repositories information. Below the usage :


An example of usage is available on Github. Download the source

References