How should I refer to inner enums (defined within an entity) from a JPQL query using Hibernate?

Viewed 3177

I have an entity class as follows:

package stuff;

@Entity
class Thing {

    @Id
    @GeneratedValue 
    private Long id;

    @Basic
    @Enumerated
    private State state;

    public enum State {
        AWESOME,
        LAME
    }
}

How can I select all Things with state AWESOME using JPQL and Hibernate?

select t from Thing t where t.state=stuff.Thing.State.AWESOME

...gives the error...

org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'stuff.Thing.State.AWESOME'
2 Answers
Related