【问题标题】:JPA - enum JOIN (JPQL)JPA - 枚举 JOIN (JPQL)
【发布时间】:2014-05-10 12:47:36
【问题描述】:

我有以下 JPQL 查询:

select cio from CadastralIncomeObjection cio where cio.dateInput < :maxValidInputDate and cio.active = true and cio.reasonInValid.valid = false "
        + "and exists (select dd from DocumentDossier dd join dd.documents d where dd.id = cio.id and d.attachmentType = be.ejb.model.entity.admin.option.REPORT)"

一切都很好,除了使用枚举。如果我会做 d.anyOtherField = someValue 查询确实编译。如果我把(正确的)枚举名称放在那里,它不会。

映射:

package be.ejb.model.entity.dossier;

@Entity
@Table(name = "DOCUMENT")
public class Document {
    @Column(name = "T_I_TYA", nullable = false)
    @Enumerated(EnumType.STRING)
    private AttachmentType attachmentType;

    /* other fields etc */

}

package be.ejb.model.entity.admin.option;

public enum AttachmentType {
    REPORT;
}

我得到的错误:

unknown identification variable [be]. The FROM clause of the query does not declare an identification variable [be]

【问题讨论】:

    标签: java jpa join enums jpql


    【解决方案1】:

    问题解决了。。 忘记在包声明后包含“AttachmentType”..

    【讨论】:

      猜你喜欢
      • 2013-07-19
      • 2012-08-22
      • 2015-10-02
      • 2013-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多