hibernate 一对一 主键代码例子

surpassdream 2012-05-17

<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<classname="additional.pojo.YuDingHotelConfig"table="yd_hotel_config">

<idname="id"column="HOTELID">

<generatorclass="foreign">

<paramname="property">hotel</param>

</generator>

</id>

<propertyname="price"type="float">

<columnname="PRICE"not-null="true"/>

</property>

<propertyname="marketPrice"type="float">

<columnname="MARKETPRICE"/>

</property>

<one-to-onename="hotel"

class="user.pojo.Hotel"

fetch="join"cascade="none"constrained="true"/>

</class>

</hibernate-mapping>

packageadditional.pojo;

importuser.pojo.Hotel;

publicclassYuDingHotelConfig{

privateLongid;

privateHotelhotel;

privateFloatprice;//全局价格

privateFloatmarketPrice;//全局市场价格

publicHotelgetHotel(){

returnhotel;

}

publicvoidsetHotel(Hotelhotel){

this.hotel=hotel;

}

publicFloatgetPrice(){

returnprice;

}

publicvoidsetPrice(Floatprice){

this.price=price;

}

publicFloatgetMarketPrice(){

returnmarketPrice;

}

publicvoidsetMarketPrice(FloatmarketPrice){

this.marketPrice=marketPrice;

}

publicLonggetId(){

returnid;

}

publicvoidsetId(Longid){

this.id=id;

}

}

相关推荐

LetonLIU / 0评论 2020-05-29
东方咖啡屋 / 0评论 2020-01-06