【发布时间】:2019-07-03 23:19:36
【问题描述】:
我想运行 Spring JPA 的 findAll() 方法,但返回所有记录,然后不返回所有记录。我想从投影返回值。喜欢
public interface StudentRepository extends CrudRepository<Student, Integer>{
//How can I achieve this
List<NamesOnly> findAll();
//Which returns list of only student names;
}
public interface NamesOnly{
@Value("#{target.firstName+ ' ' + target.lastName}")
String getFullName();
}
或者,
how to convert List<Student> given by default findAll() to List<NamesOnly>??
【问题讨论】:
标签: spring interface spring-data-jpa overriding spring-projections