hibernate的映射

①onetoone

主键关联(双向)

 

      <id name="id">

            <generator class="foreign">

            <param name="property">idCard</param>

            </generator>

        </id>

        ….

      <one-to-one name="idCard" constrained="true"/>constrained="true", 表明当前主键上存在一个约束,person

 <class name="com.org.IdCard">            的主键作为外键参照了idCard

        <id name="id">

            <generator class=“native"/>

        </id>

        ….

        <one-to-one name=“person"></one-to-one>

</class>

 唯一外键映射

<id name="id">

            <generator class="uuid"/>

        </id>

        <property name="name"/>

        <many-to-one name="nose" unique="true" cascade="all"></many-to-one>

 

        <id name="id">

            <generator class="uuid"/>

        <one-to-one name="mankind" property-ref="nose"></one-to-one>      

        </id>       

 

³property-ref:在这种情况下,必须指定此属性,它表示本类(Nose)的主键将会与关联类(Mankind)的此属性(nose)
相对应

                                          

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值