簡體   English   中英

找不到能夠從類型轉換的轉換器

[英]No converter found capable of converting from type

我有這個 class:

public class UsersXCountry {

    Integer numUsers;
    String countryCode;

}

這個查詢:

@Query(value = "select count('1'), country_code from t_user group by country_code",
        nativeQuery = true)
List<UsersXCountry> usersXCountry();

但我有這個錯誤

No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [com.losmundo.backend.domain.UsersXCountry]
    at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:322)

除了向UsersXCountry添加 getter、setter 之外,名稱必須相同

@Query(value = "select count('1') as numUsers, country_code as countryCode from t_user group by country_code",
        nativeQuery = true)
List<UsersXCountry> usersXCountry();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM