Found the answer in other threads. Looks like by default LAZY fetching
is used for @Enumerated (I don't agree here though).
If I use fetchType EAGER on this field, it works fine...
@Basic( fetch = FetchType.EAGER )
@Enumerated(EnumType.STRING)
ActionType action;
-Ajay
-----Original Message-----
From: Ajay Aggarwal [mailto:[EMAIL PROTECTED]
Sent: Monday, December 17, 2007 12:34 PM
To: [email protected]
Subject: @Enumerated (EnumType.STRING) - select query returns NULL
values
One of my fields is of enumeration type 'ActionType'. I persist it as
STRING value:
@Entity
@Table(name = "dialplan")
public class DialPlan {
...
@Enumerated(EnumType.STRING)
ActionType action;
}
When I read back the table using simple JPQL "Select X from DialPlan X",
everything else is read correctly but the value of this field is NULL
for all rows.
While persisting new entries, the field gets written to the database
correctly. Even queries like below select correct rows:
Query q = em.createQuery(
"SELECT x FROM DialPlan x where x.action = :action");
q.setParameter("action", action);
I haven't tried persisting as ORDINAL values.
Is it a bug? Has anybody else faced this?
My environment is openjap 0.97 in WebLogic 10.
-Ajay