我需要与
进行内部联接“从”
中选择rc。*"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>
答案 0 :(得分:2)
集合的inner join
应该像:
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 + "%'"
有关此主题的更多信息,请参阅手册
[1] http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html