休眠内连接

发布于 2024-11-06 02:04:13 字数 1356 浏览 0 评论 0原文

内部连接

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怀念你的温柔 2024-11-13 02:04:13

集合的内连接应该像这样完成:

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/查询hql.html

The inner join to a collection should be done like:

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 + "%'"

More on this topic at the manual

[1]http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文