hibernate三重关联
------------------------------------------------------
hibernate三重关联
组合模式
Ternary Associations (and beyond)
------------------------------------------------------
<set name="barsnafus" table="user_file_operationtype" cascade="save-update">
<key column="T_S_user_id"/>
<composite-element name="type" column="T_S_fileoperationType_id"
/>
<many-to-one cascade="save-update" name="file" column="T_S_file_id"
/>
</composite-element>
</set>
------------------------------------------------------
测试
------------------------------------------------------
@Test
public void test() {
TSysUser obj = new TSysUser("userName0001", "userPass0001", "0");
TSysFileoperationtype type=new TSysFileoperationtype();
type.setFileOperationName("type0001");
TSysFile file=new TSysFile();
file.setFileUnique("");
file.setFileName("file0001");
BarSnafu b=new BarSnafu();
b.setFile(file);
b.setType(type);
obj.getBarsnafus().add(b);
sysUserManager.saveSysUser(obj);
}
------------------------------------------------------
参考
http://www.xylax.net/hibernate/ternary.html
------------------------------------------------------