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

yunlong167167 2010-06-24 10:42:26
在做hibernate 多对一程序时,出现以下异常 java.lang.IllegalArgumentException: argument type mismatch;
代码: 一个酒店里面有多个房间
/**
* 酒店实体
*
* @author:xyl
* @E-mail: yunlong167167@163.com
* @since:2010-6-11 下午05:22:52
*
*/
public class Hotel
{
private int id;
/**
* 酒店名称
*/
private String hotelName;
//get set 省略
}
**
* 酒店房间实体
*
* @author:xyl
* @E-mail: yunlong167167@163.com
* @since:2010-6-12 上午10:21:10
*
*/
public class HotelRoom
{
/**
* id
*/
private String id;
/**
* 户型
*/
private String houseType;
/**
* 酒店ID
*/
private Hotel hotel;
//get set 省略
}
HotelRoom.hbm.xml
<class name="com.hnt66.pojo.HotelRoom" table="hotelroom">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="identity" />
</id>
<many-to-one column="hotelId" name="hotel" cascade="save-update"
class="com.hnt66.pojo.Hotel" not-null="true" />
<property name="houseType" type="string">
<column name="houseType" length="50" />
配置大概是上面那样,
然后在action中添加数据
public String add()
{
if (StringUtils.isNotBlank(hId))
{
hotel= hotelService.getHotelById(Integer.parseInt(hId));//获得酒店实体
this.hotelRoomService.save(hotel, houseType, area, floor,
directions, bedType, counterPrice, frontPrice, breakfast,
broadband, amount, paymentType, priceMark, isRecommend,
imgUrl);
}
return "add";
}
serevice 层的代码如下:
public void save(Hotel hotelId, String houseType, String area,
String floor, String directions, String bedType,
String counterPrice, String frontPrice, String breakfast,
String broadband, String amount, String paymentType,
String priceMark, String isRecommend, String imgUrl)
{
HotelRoom hotelRoom = new HotelRoom();
hotelRoom.setHotel(hotelId);
hotelRoom.setHouseType(houseType);
//......
}
代码哪里写的有问题,哪位朋友帮忙说下
...全文
408 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hoojo 2010-06-24
  • 打赏
  • 举报
回复

看你的异常,应该是参数类型匹配错误。看看的参数类型是否一致。可能是那里传递的类型错误吧。
还有你的save方法参数太多了,写得不累么。传一个对象不就over了。

52,797

社区成员

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

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