一) 加入
select rc.* from"
"from RateCode rc inner join rc.rateCodeParams rcCod where rc.rateCodeId = rcCod.id and rc.travelFrom <= 2011-05-09 and rc.travelTo >= 2011-05-13 and rc.active = 1" +
" and rcCod.paramVal like %" + roomId + "% "
rateCodeParam.hbm
<class catalog="hermes" name="RateCodeParam" table="ratecodeparam">
<id name="id" type="java.lang.Integer">
<column name="id"/>
<generator class="identity"/>
</id>
<property name="paramVal" type="string">
<column length="45" name="paramVal"/>
</property>
<many-to-one class="RateCode" insert="false" name="rateCode" update="false">
<column name="p_id"/>
</many-to-one>
</class>
rateCode.hbm
<class catalog="hermes" name="RateCode" table="ratecodes">
<id name="rateCodeId" type="java.lang.Integer">
<column name="id"/>
<generator class="native"/>
</id>
<set cascade="all, delete-orphan" name="rateCodeParams" order-by="param">
<key>
<column name="p_id"/>
</key>
<one-to-many class="RateCodeParam"/>
</set>
</class>