Hi Chris,
I've determined that the ordinal step in your example is unnecessary.
If you don't mind setting a parameter on your query, this will suffice:
"SELECT i FROM Item WHERE i.status = :value"
query.setParameter("value", ItemStatus.New)
The problem I was pointing out is that the JPQL standard allows use of
Enum Literals in query text, not just setting parameters, but that
usage does not appear to be supported in OpenJPA.
-Marc
On 11/13/07, Christian Defoy <[EMAIL PROTECTED]> wrote:
> I always use something of the form
>
> "SELECT i FROM Item WHERE i.status = :value"
> query.setParameter( "value", ItemStatus.New.ordinal() );
>
> since my enums are materialized as integers in the DB. It is related
> to the @Enumerated annotation. Using that annotation, you can specify
> that your enum type should be stored as an ordinal or as a String.
> You can maybe try to specify your enum as a String and then see if
> what you try will work any better.
>
> Christian
>
>
> On 11/12/07, Marc Siegel <[EMAIL PROTECTED]> wrote:
> > Hi folks,
> >
> > Say I have an entity Item, with an @Enumerated column 'status'.
> >
> > How can I have a named query like this:
> > "SELECT i FROM Item WHERE i.status = 'New' "
> >
> > I've tried
> > "SELECT i FROM Item WHERE i.status = 'New' "
> > "SELECT i FROM Item WHERE i.status.name = 'New' "
> > "SELECT i FROM Item WHERE i.status = ItemStatus.New "
> > "SELECT i FROM Item WHERE i.status = com.xyz.lib.ItemStatus.New "
> >
> > To no avail. Any help?
> >
> > Thanks
> > -Marc
> >
>