用于组件映射的HQL in子句

时间:2011-11-14 09:16:04

标签: java hibernate

我正在执行一个简单的选择HQL查询

from CertObjRel where certificatePrimary in (:certificatePrimaryList)  
where certificatePrimaryList is a java arrayList of certificatePrimary

CertificatePrimary类:

class CertificatePrimary implements Serializable{

    //private int primaryId;
    private String certificateId;
    private Short trsSequenceNbr;

    public String getCertificateId() {
        return certificateId;
    }

    public Short getTrsSequenceNbr() {
        return trsSequenceNbr;
    }

    public void setCertificateId(String certificateId) {
        this.certificateId = certificateId;
    }

    public void setTrsSequenceNbr(Short trsSequenceNbr) {
        this.trsSequenceNbr = trsSequenceNbr;
    }

}

CertObjRelMapping包含CertificatePrimary作为组件

CertObjRel.hbm.xml

<component name="certificatePrimary" class="com.csc.exceed.certificate.domain.CertificatePrimary">
    <property name="certificateId" type="java.lang.String" column="CERT_ID" length="36" not-null="true"/> 
    <property name="trsSequenceNbr" type="java.lang.Short" column="CERT_TRS_SEQ_NBR" />
</component>

我收到以下错误

DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=(;RT_TRS_SEQ_NBR) in (;<values>, DRIVER=3.50.152

参数绑定后会生成此错误。

1 个答案:

答案 0 :(得分:0)

据我所知 HQL in clouse不支持bean。因此,请按照以下方式修改您的查询,以便在certificateId内使用CertificatePrimary作为字符串。

from CertObjRel where certificatePrimary.certificateId in (:certificatePrimaryIdList)

certificatePrimaryIdList应该是string ,它是通过迭代certificatePrimaryList (例如'A','B','C')形成的彗星分隔的ID列表。