[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Passing array of enum to SELECT * WHERE clause

tonylmai do-not-reply at jboss.com
Tue May 22 20:27:00 EDT 2007


Hello,

I am trying to pass an array of enum to EJB EL 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):

anonymous wrote : 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?

Thanks

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047744#4047744

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047744



More information about the jboss-user mailing list