休眠内连接
内部连接
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.hbmrateCode.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>
我需要使用 “
<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>
i need inner join with
"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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
集合的
内连接
应该像这样完成:有关此主题的更多信息,请参阅手册
[1]http://docs.jboss.org/hibernate/core/3.3/reference/en/html/查询hql.html
The
inner join
to a collection should be done like:More on this topic at the manual
[1]http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html