代码:
@Override
public void delete(int id) {
// TODO Auto-generated method stub
Session session = getSession();
String hql = "delete from Services where id = ?";
Query q = session.createQuery(hql);
q.setParameter("id", id);
q.executeUpdate();
}
错误:
Servlet.service() for servlet [dispatcherServlet] in context with path [/PodCloud] threw exception [Request processing failed; nested exception is org.hibernate.QueryParameterException: could not locate named parameter [id]] with root cause
org.hibernate.QueryParameterException: could not locate named parameter [id]
at org.hibernate.engine.query.spi.ParameterMetadata.getNamedParameterDescriptor(ParameterMetadata.java:100)
at org.hibernate.engine.query.spi.ParameterMetadata.getNamedParameterExpectedType(ParameterMetadata.java:106)
at org.hibernate.internal.AbstractQueryImpl.determineType(AbstractQueryImpl.java:466)
at org.hibernate.internal.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:436)
at com.founder.mrp.dao.serviceManage.imp.ServiceManageDaoImp.delete(ServiceManageDaoImp.java:51)
at com.founder.mrp.service.bizLogic.imp.ServiceManageImp.deleteAServiceById(ServiceManageImp.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)