Code:
<collection name="popedoms" lazy="true" table="EXM_ROLE_POPEDOM" cascade="all" role="popedoms">
<key>
<column name="ROLE_ID" sql-type="INT(10)"/>
</key>
<many-to-many class="cn.mBig.experience.vo.PopedomVO">
<column name="POPEDOM_ID" sql-type="INT(10)"/>
</many-to-many>
</collection>
i got a new RoleVO object, and some PopedomVO's PK in a Long[],
i put all get all exist PopedomVOs and put it to a List, and pass it to RoleVO, and run saveOrUpdate and flush session.
the RoleVO insert success, but nothing in the link table EXM_ROLE_POPEDOM
help me...
Code:
RoleVO role = (RoleVO) obj;
PopedomDAO dao = new PopedomDAO(ds);
if (null != popedoms) {
List tmp = new ArrayList();
for (int i = 0; i < popedoms.length; i++) {
PopedomVO popdom = dao.selectByPK(popedoms[i].longValue());
tmp.add(popdom);
}
role.setPopedoms(tmp);
}
session.saveOrUpdate(role);
session.flush();