title: java.lang.IllegalArgumentException: Named query not found:
body: <p>I got the following code</p>
  
  <pre><code>@Stateless
  public class BondecomandeDAO {
  
      @PersistenceContext
      private EntityManager em;
  
      public Bondecommande findBCbyid(int id)
      {
           Query q =em.createNamedQuery("select bc from Bondecommande bc where bc.idbc = :idbc");
           q.setParameter("idbc", id);
           return  (Bondecommande) q.getResultList().get(0);
       }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Entity
  @Table(name="bondecommande")
  public class Bondecommande  implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name="idbc")
      private int idbc;
      @Column(name="devise")
      private String devise;
      @Column(name="modepaiement")
      private String modepaiement;
      @Column(name="modelivraison")
      private String modelivraison;
      @Column(name="delaipaiement")
      private int delaipaiement;
  
        ////other attributes , getters and setters 
  }
  </code></pre>
  
  <p>When I try to run the function <code>findBCbyid(int id)</code> I get this error </p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Named query not found: select bc from Bondecommande bc where bc.idbc = :idbc  </p>
  </blockquote>
  
  <p>Although I used this named query in an another project, and it worked, what could be the problem here?</p>