- ......主键关联......
TUser.hbm.xml配置文件:
xml 代码
- <one-to-one name=”passport”
- class = “com.winchannel.base.TPassPort”
- cascade = “all”
- outer-join = “true”
- />
TPassPort.hbm.xml配置文件:
xml 代码
- <one-to-one name=”user”
- class = “com.winchannel.base.User”
- cascade = “all”
- constrained = " true "
- />
配置参数说明:
cascade = " all " 设置及联关系,all表示无论主控方执行任何操作都对其关联类进行同样的操作。
constrained = " true " 表示主键上存在一个约束
2、......唯一外键关联......
User.hbm.xml配置文件:
xml 代码
- <many-to-one
- name = “group”
- calss = “com.wiinchannel.base.Group”
- column = “GROUP_ID”
- unique = “true”
- />
通过指定unique="true",我们可以把关联性从多对多改变为一对多
TGroup.hbm.xml配置文件:
xml 代码
- <one-to-one
- name = “group”
- calss = “com.wiinchannel.base.User”
- property-ref = “group” //指向User group属性
- />