Bean类[java.math.BigInteger]的无效属性“ count”:在后备访问期间找不到属性的字段

时间:2019-06-22 12:56:26

标签: java hibernate spring-boot jpa

我正在尝试使用nativeQuery根据条件获取行数并将其分配给DTO,但出现以下错误:

Invalid property 'count' of bean class [java.math.BigInteger]: Could not find field for property during fallback access!

下面是DTO:

public interface CountDto {

    Integer getCount();

}

下面是查询:

public interface DoctorPracticeUserRepository extends JpaRepository<DoctorPracticeUser, Long> {

    @Query(value = "select count(*) as count from orders o inner join treatments t on o.treatment_id = t.id where o.status = 'PAYMENT_APPROVED' and o.product = :product  and t.doctor_user_id = :doctorUserId" , nativeQuery = true)
    public CountDto getSalesByProdcutForDoctor(@Param("doctorUserId") Long doctorUserId, @Param("product") String product);

}

getSalesByProdcutForDoctor()执行得很好,但是当我对结果调用getCount()时,我得到了上面提到的错误。

我尝试将count(*)强制转换为intvarchar,并在DTO中相应地更改类型,但仍然收到类似的错误,只是将BigInteger更改为{{1} }或Integer

还尝试了DTO中的不同类型,例如StringLongBigIntger,但是仍然发生相同的错误。

我知道我可以通过许多其他方式获得此查询的结果,但是我想知道为什么这行不通。

编辑:堆栈跟踪

BigDecimal

0 个答案:

没有答案