argument type mismatch异常问题
今天看一个项目的时候出现了这个问题。
严重: Servlet.service() for servlet [action] in context with path [/myshop] threw exception [org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred while calling setter of emp.shop.model.Orders.orderItem; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of emp.shop.model.Orders.orderItem] with root cause
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
提示实在这两部分报错
aciton部分的 request.setAttribute("back_order", order);
action完整代码:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
OrderForm of = (OrderForm)form;
int order_id = of.getOrder_id();
ApplicationContext app = new ClassPathXmlApplicationContext("applicationContext-*.xml");
IOrderDao orderDao = (IOrderDao)app.getBean("orderDaoProxy");
Orders order= (Orders)app.getBean("order");
order = orderDao.queryOrderByOrderId(order_id);
request.setAttribute("back_order", order);
return mapping.findForward("success");
}
daoimpl部分: Orders orders = (Orders) this.getHibernateTemplate().find("from Orders where order_id =" +order_id);
daoImpl完整代码:
public class OrderDaoImpl extends HibernateDaoSupport implements IOrderDao {
public void addOrder(Orders orders) {
this.getHibernateTemplate().save(orders);
}
public void deleteOrder(int order_id) {
}
public void modifyOrder(int order_id) {
}
public Orders queryOrderByUserId(int user_id) {
List orderList = this.getHibernateTemplate().find("from Orders where user.user_id='"+user_id+"'");
Orders orders = null;
if(orderList.size() == 1){
orders = (Orders) orderList.get(0);
}
return orders;
}
public List<Orders> queryOrderByList(int user_id) {
List<Orders> orderList = this.getHibernateTemplate().find("from Orders where user.user_id="+user_id);
return orderList;
}
public Orders queryOrderByOrderId(int order_id) {
Orders orders = (Orders) this.getHibernateTemplate().find("from Orders where order_id =" +order_id);
return orders;
}
}
hbm.xml部分
<hibernate-mapping package="emp.shop.model">
<class name="Orders">
<id name="order_id">
<generator class="native"/>
</id>
pojo部分
private int order_id;
请大家帮忙看看