2 Replies Latest reply on May 23, 2007 1:44 PM by Tony Mai

    Passing array of enum to SELECT * WHERE clause

    Tony Mai Apprentice


      I am trying to pass an array of enum to EJB QL as followed:

      em.createQuery("FROM OrderInfo o WHERE o.ordStatus IN (:ordStatus)")
       .setParameter("ordStatus", ordStatsStr)

      Note that o.ordStatus is of type enum OrderStatus.

      I've tried to set "ordStatus" as String (i.e. 'OPEN', 'CLOSED'), as well as an array of enum but Hibernate would not parse them (perhaps for a good reason). Hibernate threw the following exception (or similar depending on whether I passed in an array of enum or a String):

      org.hibernate.TypeMismatchException: named parameter [ordStatus] not of expected type; expected = class ....OrderStatus; but was =java.lang.String

      Can someone show me the way to set the IN clause in Hibernate?