1 Reply Latest reply on May 7, 2008 2:05 PM by joost maenen

    Problem with ENUM in entityQuery ( restrictions )

    joost maenen Newbie

      Hello,


      Currently we have a class which extends entity query, in this class we have a restriction which uses an Hello,


      Currently we have a class which extends entity query, in this class we have a restriction which uses the enum as query parameter. The Enum is defined as String type.


      Problem is that when the query is executed no rows are returned ( when the query should return rows ).
      When debugging  i see that the enum used is of the type ordinal. So it looks the defined enum type  is not used.


      Question is have other people encountered the same problem and is how did they fix it ..


      Is there an example of how using enum is entity query.


      regards
      a happy seam user

        • 1. Re: Problem with ENUM in entityQuery ( restrictions )
          joost maenen Newbie

          entity query 
          
          
          public class PatientList extends EntityQuery {
          
          private static final String[] RESTRICTIONS = {
               "state is concat(#{patientList.patient.state},'%')",
               "therapist.id is concat(#{therapistHome.therapistId},'%')"
                         };
          
               public String getEjbql() {
                    return "select patient from Patient patient";
               }
          
          Entity bean and enum ....
          
          public class Patient implements Serializable {
          
               public enum PatientState {
                NEW,
                ACTIVE,
                SUSPENDED,
                CLOSED;
          
          
          Definition in entity 
          
               @Enumerated(EnumType.STRING)
               public PatientState getState() {
                    return this.state;
               }