在@Query中使用BigDecimal字段并在@Param字段中填充它会引发Sql错误

时间:2019-05-07 10:09:51

标签: spring-data-jpa

以下是我用于在Query中设置BigDecimal值但由于SQL语法错误而失败的查询

@Query(value="Select f.id,s.student_id,f.feesPaid,f.fees_pending,f.paid_datetime from Fees f inner join Student s where f.feesPaid > :amt")
    List<Fees> findFirst3ByFeesPaidGreaterThan( @Param(value = "amt") BigDecimal amt);

以下是错误

Hibernate: select fees0_.id as col_0_0_, student1_.student_id as col_1_0_, fees0_.fees_paid as col_2_0_, fees0_.fees_pending as col_3_0_, fees0_.paid_datetime as col_4_0_ from fees fees0_ inner join student student1_ on where fees0_.fees_paid>?
2019-05-07 20:06:16.779  WARN 21752 --- [nio-8082-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1064, SQLState: 42000
2019-05-07 20:06:16.779 ERROR 21752 --- [nio-8082-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where fees0_.fees_paid>500' at line 1

我能够使用查询方法名称,但是我想如上所述使用Query来实现。

0 个答案:

没有答案