我有一个 @SQLDelete 注释定义为 -
@SQLDelete(sql = "UPDATE item SET deleted = 1 WHERE id = ? and version=? ")
当我调用 delete 时,item
我无法通过version
并且出现以下异常 -
org.springframework.dao.InvalidDataAccessResourceUsageException: could not delete:
com.hk.domain.order.Item#30000004]; SQL [UPDATE item SET deleted = 1 WHERE id = ? and
version=? ]; nested exception is org.hibernate.exception.SQLGrammarException: could not
delete: [com.hk.domain.order.Item#30000004]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:629)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
.
.
.
.
Caused by: java.sql.SQLException: No value specified for parameter 2
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2513)
at com.mysql.jdbc.PreparedStatement.addBatch(PreparedStatement.java:1007)
at org.apache.commons.dbcp.DelegatingPreparedStatement.addBatch(DelegatingPreparedStatement.java:175)
at org.apache.commons.dbcp.DelegatingPreparedStatement.addBatch(DelegatingPreparedStatement.java:175)
at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:53)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2548)
... 93 more
我认为应该从item
对象本身获取版本,但这并没有发生。
反正有没有通过版本?当有超过 1 个参数时如何使用此注释?我到处寻找,但对于有 2 个参数的情况,找不到任何解决方案。
提前致谢。