[英]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.