我有以下JPA实体
@SQLDelete(sql="UPDATE service SET date_deletion = CURRENT_DATE() WHERE id = ?")
@Where(clause="date_deletion IS NULL ")
public class Service {
...
}
选择工作确定所有通知date_deletion的元素都不显示,但是当我尝试删除....
16:38:26,836 DEBUG SQL:111 - UPDATE service SET date_deletion = CURRENT_DATE() WHERE id = ?
16:38:26,836 DEBUG AbstractBatcher:418 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
16:38:26,836 DEBUG JDBCExceptionReporter:225 - could not delete: [com.foo.domain.Service#1] [UPDATE service SET date_deletion = CURRENT_DATE() WHERE id = ?]
java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).
SQL有什么问题?看起来像尝试处理CURRENT_DATE()作为参数并期望2个参数而不是1 ...
答案 0 :(得分:3)
固定。 我正在使用Spring Roo在内部处理作为参数发送的“版本”字段,正确的anotation是:
@SQLDelete(sql="UPDATE service SET date_deletion=CURRENT_DATE WHERE id=? and version=? ")
@Where(clause="date_deletion IS NULL ")
public class Service {
...