提取年份表单日期mysql

时间:2015-09-16 09:32:11

标签: spring spring-data-jpa

我使用的是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'!

1 个答案:

答案 0 :(得分:0)

删除“:”和参数之间的空格:

... "where extract(year from rec.closingDate) = :closingDate"