2 Replies Latest reply on May 31, 2006 11:56 PM by Clebert Suconic

    @NamedQueries Question

    Clebert Suconic Master

      What am I doing wrong here?

       @javax.persistence.NamedQuery(name="selectAllWorkOrders",query="select a from WorkOrder"),
       @javax.persistence.NamedQuery(name="selectWorkOrder",query="select a from WorkOrder a where a.id=:id")
      @Stateless public class WorkOrderSession implements IWorkOrderSession{
       @PersistenceContext EntityManager em;
       @EJB IMfgSession mfgSession;
       public Collection<WorkOrder> getAllWorkorders()
       return (Collection<WorkOrder>)em.createNamedQuery("selectAllWorkOrders").getResultList();
       public WorkOrder getWorkOrder(Integer id)
       return (WorkOrder)em.createNamedQuery("selectWorkOrder").setParameter("id", id).getSingleResult();

      When I execute my testcase I'm getting:

      Named query not known: selectAllWorkOrders

      If instead of using @NamedQueries I just use a single @NamedQuery it works. I will have a bunch of Sessions with Several NamedQueries.