在做hibernate 多对一 java.lang.IllegalArgumentException: argument type mismatch
在做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);
//......
}
代码哪里写的有问题,哪位朋友帮忙说下