| Issue 35: | SQL error when using an enum | |
| 1 person starred this issue and may be notified of changes. | Back to list |
I wanted to add a conditionnal expression with an enum.
I had something like :
ConditionalExpression ce = eq(myObject.getEnumValue(), EnumValue.VALUE);
It produces the JPA code :
myObject.enumValue = VALUE
When the JPA query is translated in SQL, the query is not valid with the
database schema. I tried to do something :
ConditionalExpression ce = eq(myObject.getEnumValue(),
EnumValue.VALUE.name());
But it did not compile, because of the generics. So I download the sources
of the project and I add :
else if (what.getClass().isEnum()) {
return escape(what.toString());
}
It produces : myObject.enumValue = 'VALUE'
In my case, it was what I wanted because of the JPA annotation
'@Enumerated(EnumType.STRING)'. It would be better to support the fact that
if it was '@Enumerated(EnumType.ORDINAL)', it should produce the correct value.
PS: Sorry for this long issue :)
Jan 15, 2009
Project Member
#1
eric.bot...@gmail.com
Jan 15, 2009
(No comment was entered for this change.)
Labels:
Milestone-Release1.0
|