2013-01-21 29 views
1

我有以下的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 ...

回答

3

固定。 我正在使用Spring Roo在内部处理作为参数发送的“版本”字段,正确的注释是:

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