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;
请大家帮忙看看
...全文
179 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧