com.codingapi.springboot.fast.jpa.repository.BaseRepository Maven / Gradle / Ivy
package com.codingapi.springboot.fast.jpa.repository;
import org.springframework.core.ResolvableType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;
@NoRepositoryBean
public interface BaseRepository extends JpaRepository {
@SuppressWarnings("unchecked")
default Class getEntityClass() {
ResolvableType resolvableType = ResolvableType.forClass(getClass()).as(BaseRepository.class);
return (Class) resolvableType.getGeneric(0).resolve();
}
}