argument type mismatch异常问题

Marstary 2015-11-06 11:31:59
今天看一个项目的时候出现了这个问题。
严重: 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;
请大家帮忙看看
...全文
63 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-11-06 11:31
社区公告
暂无公告