我想用spring 4框架删除dao。但发生MariaDB
错误。但我使用XAMPP db
我的代码是
@Override
public void makeDelete(Long id) {
sessionFactory.getCurrentSession()
.createQuery("delete from Employee c where c.id:id")
.setParameter("id", id).executeUpdate();
}
错误
[Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near
答案 0 :(得分:0)
将"where c.id:id"
更改为"where c.id = :id"
。