我在Question实体中具有以下内容:
@NamedQuery(name = "Question.allApproved",
query = "SELECT q FROM Question q WHERE q.status = 'APPROVED'")
和
@Enumerated(EnumType.STRING)
private Status status;
// usual accessors
我收到此异常:
异常描述:编译查询[Question.countApproved:
SELECT COUNT(q) FROM Question q WHERE q.status = 'APPROVED'
],第1行,第47列:无效的枚举等于表达式时出错,无法将type的enum值与type[myCompnay.application.Status]
的非enum值进行比较[java.lang.String]
。在org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:501)
我该如何解决?