views:

287

answers:

2

I have an Entity with a enum attribute and a couple on NamedQueries. One of these NamedQueries has the enum attribute as a parameter i.e.

SELECT m FROM Message m WHERE m.status = :status

When i try to ru n the query i get the following error;

Caused by: java.lang.IllegalArgumentException: You have attempted to set a value of type class my.package.Status for parameter status with expected type of class my.package.Status from query string SELECT m FROM Message m WHERE m.status = :status.

I'm using Toplink

How is this? How would i make JPA happy?

+1  A: 

Enum objects can be used as query parameters just like any other objects. You query however should probably be:

SELECT m FROM Message m WHERE m.status = :status

Also - have added the @Enumerated in the entity definition?

Bozhidar Batsov
that was a typo on the question, the query is as you have noted, by @EnumeratedType you mean @Enumerated, yes
n002213f
related to http://goo.gl/Ue6M and http://goo.gl/fvhy unfortunately they are no solutions
n002213f
I'm using always hibernate, not TopLink/EclipseLink - maybe this is some bug there...
Bozhidar Batsov
A: 

This is a bug. I shuffled around the parameters and the query executes.

n002213f