我想对一个表的很多记录批量删除,是根据前台传过来的ID来删,代码如下:
public List findListByHql(String deletelist[]){
List list = new ArrayList();
for(int i=0;i<deletelist.length;i++){
String hql="from AgentContact ac where ac.id='"+deletelist[i]+"'";
Query query=this.getQuery(hql);
list.add(query.list());
}
return list;
}
public void deleteContact(String deletelist[]) throws AppException {
List list = this.findListByHql(deletelist);
this.getHibernateTemplate().deleteAll(list);
}
是根据deletelist这个数组里面的ID来删除,但我这样写会报错,因为对SSH不熟,怎么做呢,请大家指点一下,下面是错误信息
exception
javax.servlet.ServletException: Unknown entity: java.util.ArrayList; nested exception is org.hibernate.MappingException: Unknown entity: java.util.ArrayList
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: java.util.ArrayList; nested exception is org.hibernate.MappingException: Unknown entity: java.util.ArrayList
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:668)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:408)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
org.springframework.orm.hibernate3.HibernateTemplate.deleteAll(HibernateTemplate.java:787)
com.fordays.fdpay.agent.dao.AgentDAOImpl.deleteContact(AgentDAOImpl.java:143)
com.fordays.fdpay.agent.biz.AgentBizImpl.deleteContact(AgentBizImpl.java:107)
com.fordays.fdpay.agent.action.AgentListAction.deleteContact(AgentListAction.java:100)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
com.neza.base.BaseAction.execute(BaseAction.java:25)
org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause