hibernate三重关联

------------------------------------------------------------------------------------------
hibernate三重关联
组合模式
Ternary Associations (and beyond)
------------------------------------------------------------------------------------------
    
<set name="barsnafus" table="user_file_operationtype" cascade="save-update">
        <key column="T_S_user_id"/>
      
        <composite-element class="com.[xx].fms.common.model.pojo.BarSnafu">
      
            <many-to-one cascade="save-update" name="type" column="T_S_fileoperationType_id"
                class="com.[xx].fms.common.model.pojo.TSysFileoperationtype" />
              
              
           <many-to-one cascade="save-update" name="file" column="T_S_file_id"
                class="com.[xx].fms.common.model.pojo.TSysFile" />
        </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

------------------------------------------------------------------------------------------

你可能感兴趣的:(html,Hibernate,.net)