I have an abstract class annotated with @MappedSuperClass
. There are around 15 entities that extend this abstract class (having 15 corresponding tables in the d
You will have to create repository for each class. However you can keep your methods in the abstract. You'll need to provide @Query
on each of the methods and use SpeL(Spring Expression Language) to add the type to the queries.
@NoRepositoryBean
public interface AbstractRepository
extends CrudRepository{
@Query("select e from #{#entityName} as e from equipment where e.name = equipmentName")
T findEquipmentByName(String equipmentName);
}
Then extend like the following
@Transactional
public interface SpecialEquipmentRepo extends AbstractRepository{
}