来自
docs
像这样定义一个接口
public interface StudentRepositoryCustom { List<String> nameByCourse(String coursename);}
然后像这样定义此接口的自定义实现
@Serviceclass StudentRepositoryImpl implements StudentRepositoryCustom { @PersistenceContext private EntityManager em; public List<String> nameByCourse(String coursename) { CriteriaBuilder cb = em.getCriteriaBuilder(); //Using criteria builder you can build your criteria queries. }}
现在,您可以像这样在JPA存储库中扩展此自定义存储库实现。
public interface StudentRepository extends CrudRepository<StudentEntity, Integer>, StudentRepositoryCustom {}
了解有关条件查询和条件构建器的更多信息
here
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)