I have an abstract class annotated with @MappedSuperClass
. There are around 15 entities that extend this abstract class (having 15 corresponding tables in the database). The 15 entities all have the same attributes that are inherited from the abstract super class.
I have created a repository as below for the abstract class:
@NoRepositoryBean
public interface AbstractRepository <T extends AbstractClass, E extends Serializable>
extends PagingAndSortingRepository<T, Serializable> {
.....some methods here
}
The 15 entities/tables store some data (data pertaining to 15 separate equipment). Based on the equipment selected, the data from that table is to be retrieved. Will I have to create 15 separate repositories for the 15 concrete entities or is there any way to get the specific entity for the equipment selected using only the abstract repository? If repositories need to be created for each concrete entity, how to get the right repository for the specific equipment call? (store the table name and repository class in a map that gets created on startup of the application perhaps?)