1 Reply Latest reply on May 6, 2005 5:22 PM by Emmanuel Bernard

    Filters in EJB3

    Robin Young Newbie

      I've been experimenting with trying to use the filter feature of Hibernate from a stateless session bean but haven't managed to get it to work. Has anyone tried this and can give mesome pointers?

      I inject the EntityManager as per usual in my stateless and then runthe following:-

      Session session = ((HibernateSession) this.manager).getHibernateSession();
      session.enableFilter("byRole").setParameter("filterId", new Long(400));


      In my entity bean I have
      @FilterDef(name = "byRole", parameters = {@ParamDef(name = "filterId", type = "long") })
      @Filter(name = "byRole", condition = "id > :filterId")


      If I call getResultList() on a named query I'd expect the results to be limited to those with an id > 400 but its as if the filter isn't being applied.

      BTW
      org.hibernate.Query has a method on it called getNamedParameters(),
      it would be nice if this could make it through to javax.persistence.Query in the ejb3 spec.