hibernate 一对一 主键代码例子
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="additional.pojo.YuDingHotelConfig" table="yd_hotel_config">
<id name="id" column="HOTELID">
<generator type="float">
<column name="PRICE" not-null="true" />
</property>
<property name="marketPrice" type="float">
<column name="MARKETPRICE"/>
</property>
<one-to-one name="hotel"
fetch="join" cascade="none" constrained="true"/>
</class>
</hibernate-mapping>
package additional.pojo;
import user.pojo.Hotel;
public class YuDingHotelConfig {
private Long id;
private Hotel hotel;
private Float price;//全局价格
private Float marketPrice;//全局市场价格
public Hotel getHotel() {
return hotel;
}
public void setHotel(Hotel hotel) {
this.hotel = hotel;
}
public Float getPrice() {
return price;
}
public void setPrice(Float price) {
this.price = price;
}
public Float getMarketPrice() {
return marketPrice;
}
public void setMarketPrice(Float marketPrice) {
this.marketPrice = marketPrice;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}