Hibernate HQL Query:如何使用复合键将Collection设置为Query的命名参数?

Hibernate HQL Query:如何使用复合键将Collection设置为Query的命名参数?

问题描述:

给出以下HQL查询:

来自Foo foo,其中foo.id in(:fooIds)

from Foo foo where foo.id in (:fooIds)

但是我在Id中有复合键,我们有两个PK1和pk2作为Id。

but here i have composite key in the Id ex we have two PK1 and pk2 as Id's.

我们如何实现这个查询..

How can we implement this query..

如何在查询的setparameters函数中传递两个参数

how can i pass both paramets in setparameters function of query

我的问题类似于问题

包含复合键的HBM文件位于

HBM file containing composite key is present below

<?xml version="1.0"?>


    <composite-id>
        <key-property name="foo1" column="FOO1" type="java.lang.String" length="36"/>
        <key-property name="foo2" column="FOO2" type="java.lang.Short" />       
    </composite-id>

    <property name="EffectiveDt" type="java.sql.Date"  column="EFFECTIVE_DT" />             
    <property name="effectiveTypeCd" type="java.lang.String" column="CERT_EFF_TYPE_CD" />
    <property name="statusCd" type="java.lang.String" column="CERT_STATUS_CD" />


</class>

您使用的是复合ID吗?您是否有一个表示复合ID的单独类,或者您在Foo中有2个字段,并且您想在查询中使用它们进行搜索?
发帖给你Foo课会有所帮助!

Are you using a composite id? Do you have a separate class representing the composite-id or do you have 2 fields in Foo and you want to search using them in your query? Posting you Foo class would help!