java.lang.IllegalArgumentException: argument type mismatch

在mysql取出int类型的数据时,在java中却是Long类型的.此时实体属性类型为int就会报错,参数类型不匹配....

同样的事情也会使用orcale数据库时出现...

修改属性类型和对应getter 返回类型和setter的参数类型即可....

阅读更多

在做hibernate 多对一 java.lang.IllegalArgumentException: argument type mismatch

06-24

在做hibernate 多对一程序时,出现以下异常 java.lang.IllegalArgumentException: argument type mismatch;rn代码: 一个酒店里面有多个房间rn/** rn * 酒店实体rn * rn * @author:xylrn * @E-mail: yunlong167167@163.comrn * @since:2010-6-11 下午05:22:52rn * rn */rnpublic class Hotelrnrn private int id;rn /**rn * 酒店名称rn */rn private String hotelName;rn//get set 省略rnrn**rn * 酒店房间实体rn * rn * @author:xylrn * @E-mail: yunlong167167@163.comrn * @since:2010-6-12 上午10:21:10rn * rn */rnpublic class HotelRoomrnrn /**rn * idrn */rn private String id;rn /**rn * 户型rn */rn private String houseType;rn/**rn * 酒店IDrn */rn private Hotel hotel;rn//get set 省略rnrnHotelRoom.hbm.xmlrnrn rn rn rn rn rn rn rn配置大概是上面那样,rn然后在action中添加数据rn public String add()rn rn if (StringUtils.isNotBlank(hId))rn rn hotel= hotelService.getHotelById(Integer.parseInt(hId));//获得酒店实体rn this.hotelRoomService.save(hotel, houseType, area, floor,rn directions, bedType, counterPrice, frontPrice, breakfast,rn broadband, amount, paymentType, priceMark, isRecommend,rn imgUrl);rn rn return "add";rn rnserevice 层的代码如下:rnpublic void save(Hotel hotelId, String houseType, String area,rn String floor, String directions, String bedType,rn String counterPrice, String frontPrice, String breakfast,rn String broadband, String amount, String paymentType,rn String priceMark, String isRecommend, String imgUrl)rn rnHotelRoom hotelRoom = new HotelRoom();rn hotelRoom.setHotel(hotelId);rn hotelRoom.setHouseType(houseType);rn //......rnrn代码哪里写的有问题,哪位朋友帮忙说下

没有更多推荐了,返回首页