我想用spring 4框架删除dao。但发生MariaDB错误。但我使用xampp db

时间:2018-02-27 11:04:50

标签: spring hibernate spring-mvc

我想用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 

1 个答案:

答案 0 :(得分:0)

"where c.id:id"更改为"where c.id = :id"