7.映射组成关系
来源:互联网 发布:淘宝复制天猫宝贝违规 编辑:程序博客网 时间:2024/06/06 02:18
public class Customer implements java.io.Serializable {<span style="white-space:pre"></span>private Integer id;<span style="white-space:pre"></span>private String name;<span style="white-space:pre"></span>private Address homeAddress;<span style="white-space:pre"></span>private Address comAddress;
配置文件配置如下
<component name="homeAddress" class="cn.itcast.compopent.Address"> <!-- 该配置表示Address是Customer类的一部分 --> <property name="street" type="string"> <column name="home_street"></column> </property> <property name="city" type="string"> <column name="home_city"></column> </property> <property name="province" type="string"> <column name="home_province"></column> </property> <property name="zipcode" type="string"> <column name="home_zipcode"></column> </property> </component> <component name="comAddress" class="cn.itcast.compopent.Address"> <property name="street" type="string"> <column name="com_street"></column> </property> <property name="city" type="string"> <column name="com_city"></column> </property> <property name="province" type="string"> <column name="com_province"></column> </property> <property name="zipcode" type="string"> <column name="com_zipcode"></column> </property> </component>
* 两个javabean对应一张表,组件映射表中字段一般有重复内容,比如说地址,有家庭地址和公司地址
Address ha=c.getHomeAddress();* 如果homeAddress对应的四个表字段为空 则c.getHomeAddress()为null
public class Address {private String street;private String city;private String province;private String zipcode;//表示Address所属的整体类private Customer customer;hbm配置文件
<component name="homeAddress" class="cn.itcast.compopent.Address"> <!-- 该配置表示Address是Customer类的一部分 --> <parent name="customer"/> <property name="street" type="string"> <column name="home_street"></column> </property> <property name="city" type="string"> <column name="home_city"></column> </property> <property name="province" type="string"> <column name="home_province"></column> </property> <property name="zipcode" type="string"> <column name="home_zipcode"></column> </property> </component>* 在Address类中加上所属类,配置文件加一个parent标签也可以
0 0
- 7.映射组成关系
- Hibernate映射组成关系
- Hibernate 映射组成关系
- Hibernate映射组成关系
- hibernate映射组成关系
- Hibernate -- 映射组成关系
- hibernate 映射组成关系
- 1009--映射组成关系
- Hibernate 映射组成关系
- -映射组成关系
- Hibernate映射组成关系
- 映射组成关系
- 映射组成关系
- Hibernate之映射组成关系
- Hibernate映射组成关系简析
- hibernate 映射组成关系(第六章)
- 精通Hibernate——映射组成关系
- hibernate映射 【映射组成关系】,初学例子五
- 集训小记 4
- Kafka#3:分布式设计
- LeetCode--Min Stack
- ceph存储 iSCSI完全指南
- SDUTOJ3108-赏赏赏
- 7.映射组成关系
- epoll 解析
- android 源码环境 启动模拟器
- JQuery中的事件以及动画
- android rtsp流媒体播放介绍
- [乐意黎原创] 谷歌chorme浏览器开发版假死解决办法
- android studio开发工具
- 用命令测试安装好的OpenStack环境
- 使用JS实现页面倒数计数