我使用的是spring-data-jpa,我希望从日期开始提取年份。
@Query("select t from Table t where extract(year from t.date) =: date")
Set<Table> extractYear(@Param("date") Integer date);
但它给了我一个错误
Using named parameters for method public abstract java.util.Set com.repositroy.extratYear(java.lang.Integer) but parameter 'date' not found in annotated query 'select t from Table t where extract(year from t.date) =: date'!
答案 0 :(得分:0)
删除“:”和参数之间的空格:
... "where extract(year from rec.closingDate) = :closingDate"