【问题标题】:Querydsl: JPAUpdateClause with multiple sourcesQuerydsl:具有多个来源的 JPAUpdateClause
【发布时间】:2013-05-30 19:08:29
【问题描述】:

我是 Querydsl 的新手,所以这个问题对你们中的一些人来说可能看起来很愚蠢:)

这是我想做的:

QAppt qApptRqst = QAppt.apptRqst;
QLocZip qLocZip = QLocZip.locZip;

JPAQuery query = new JPAQuery(em);

JPAUpdateClause upd = new JPAUpdateClause(em, qApptRqst);
upd.where(qApptRqst.apptRqstStatusRef.apptRqstStatusCd.eq("U"),
qApptRqst.applZip5Cd.eq(qLocZip.usZip5Cd))
   .set(qApptRqst.uscisLocation.uscisLocCd, qLocZip.uscisLocCd)
   .execute();

我有以下异常:

"java.lang.IllegalArgumentException: Undeclared path 'locZipJuris'. Add this path as a source to the query to be able to reference it."

如何将 JPAUpdateClause 用于多个来源?

【问题讨论】:

    标签: querydsl


    【解决方案1】:

    您可以在更新语句中使用子查询,如下所示。

    upd.set(qApptRqst.xx, new JPASubQuery().from(qLocZip).where(qLocZip.usZip5Cd.eq(qApptRqst.applZip5Cd)).unique(qLocZip.locCd))
                 .where((qApptRqst.apptRqstStatusRef.eq("NA")))
                 .execute();
    

    【讨论】:

      【解决方案2】:

      JPA 仅支持 DML 更新的单一来源,在您的情况下,子查询可能会起作用。

      【讨论】:

        猜你喜欢
        • 2015-01-06
        • 1970-01-01
        • 1970-01-01
        • 2010-11-10
        • 2014-05-02
        • 2021-12-25
        • 2019-08-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多