使用休眠注释进行软删除时出错



我有以下JPA实体

@SQLDelete(sql="UPDATE service SET date_deletion =  CURRENT_DATE() WHERE id = ?")
@Where(clause="date_deletion IS NULL ")
public class Service {
...
}

选择工作ok所有元素与date_delete通知不显示,但当我试图删除....

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()作为参数,并期望两个参数而不是1…

修复。我使用Spring Roo内部处理一个"版本"字段,作为参数发送,正确的注释是:

@SQLDelete(sql="UPDATE service SET date_deletion=CURRENT_DATE WHERE id=? and version=? ")
@Where(clause="date_deletion IS NULL ")
public class Service {
...

相关内容

  • 没有找到相关文章

最新更新