package com.coracle.yk.xpo.po.base; import java.util.Date; import java.util.HashSet; import java.util.Set;public class YkAction { private static final long serialVersionUID = 1L; private Integer id;private Set<YkColumn> ykColumns = new HashSet<>(); public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Set<YkColumn> getYkColumns() { return ykColumns; } public void setYkColumns(Set<YkColumn> ykColumns) { this.ykColumns = ykColumns; } }
YkAction.hbm.xml
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="com.coracle.yk.xpo.po.base.YkAction" table="yk_action" catalog="youkee_base"> <id name="id" type="java.lang.Integer"> <column name="ID" /> <generator class="com.coracle.yk.xframework.common.db.HibernateIncrementGenerator"> <param name="catalog">youkee_base</param> </generator> </id> <!-- 行为动作多对多映射 --> <set name="ykColumns" table="yk_action_column" order-by="sort_order asc"> <key column="ACTION_ID"></key> <many-to-many class="com.coracle.yk.xpo.po.base.YkColumn" column="COLUMN_ID" where="remove_flag=0"/> </set> </class> </hibernate-mapping>
使用子查询.
<set name="stores" subselect="org_id in (select ID from yk_org org where org.id = org_id and org.remove_flag=0)"> <key column="mall_id"></key> <one-to-many class="com.coracle.yk.xpo.po.base.YkStore"></one-to-many> </set>