argument type mismatch异常问题

Marstary Marstary 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
今天看一个项目的时候出现了这个问题。
严重: 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;
请大家帮忙看看
...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
Marstary
Web 开发 81,108 成员 341,721 内容