小编Ash*_*pta的帖子

Spring数据jpa,jparepository返回字符串列表代替DTO对象

我有一个interface实现JPARepository,有三个方法,其中一个是自定义@Query.

public interface PersonRepository extends JpaRepository<Person, Long> {

  List<Person> getPersonBycountryCode(String countryCode);

  List<Person> findByCountryCodeAndCity(String string,String city);

  @Query(value = "SELECT person.firstName as firstName, person.lastName as lastName, person.countryCode as country, person.city as city,"
              + " SQRT(POWER((69.1 * (person.age - :age )) , 2 )"
              + " + POWER((53 * (person.experience - :experience )), 2)) as eligibility"
              + " FROM Person person"
              + " ORDER BY eligibility ASC")
  List<PersonDetailsDto> findPersonDetailsByEligibility(
          @Param("age") BigDecimal age,
          @Param("experience") BigDecimal experience,
          Pageable pageable …
Run Code Online (Sandbox Code Playgroud)

java spring jpa spring-data spring-data-jpa

5
推荐指数
1
解决办法
9146
查看次数

标签 统计

java ×1

jpa ×1

spring ×1

spring-data ×1

spring-data-jpa ×1