我应该如何使用Hibernate从JPQL查询中引用内部枚举(在实体中定义)?
我有一个实体类,如下所示:
package stuff;
@Entity
class Thing {
@Id
@GeneratedValue
private Long id;
@Basic
@Enumerated
private State state;
public enum State {
AWESOME,
LAME
}
}
如何使用JPQL和Hibernate选择状态为AWESOME的所有内容?
select t from Thing t where t.state=stuff.Thing.State.AWESOME
...给出错误...
org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'stuff.Thing.State.AWESOME'