首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

hibernate 一对一 主键代码例证

2012-07-02 
hibernate 一对一 主键代码例子?xml version1.0 encodingUTF-8?!DOCTYPE hibernate-mapping PUBL

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;
}



}

热点排行