title: Error: Parameter value did not match expected type
body: <p>I am trying to retrieve a USER from my database using the ID in the WHERE clause.  However I am receiving an error and my program is failing.</p>
  
  <p>This is the error I'm receiving when I run my program:</p>
  
  <pre><code>ERROR [org.jboss.as.ejb3.invocation] (default task-19) 
  JBAS014134: EJB Invocation failed on component CustomerServiceBeanImpl 
  for method public abstract package.name.entity.ICustomer 
  package.name.bean.CustomerServiceBean.getCustomerById(long): 
  javax.ejb.EJBException: java.lang.IllegalArgumentException: 
  Parameter value [19533] did not match expected type [package.name.entity.User (n/a)]
  </code></pre>
  
  <p><em>Note: [19533] is a test value I used.</em></p>
  
  <p>This is the method that is having the error in the CustomerServiceBeanImpl.java:</p>
  
  <pre><code>@Override
  public Customer getCustomerById (final long id)
  {
      return Customer.getById (this.em, id);
  }
  </code></pre>
  
  <p>This is the method that's being called by the component CustomerServiceBeanImpl:</p>
  
  <pre><code>public static Customer getById (final EntityManager em, final long id)
  {
      for (final Customer c : em.createNamedQuery ("Customer.getById", Customer.class)
      .setParameter ("id", id).setMaxResults (1).getResultList ())
      {
          return c;
      }
      return null;
  }
  </code></pre>
  
  <p>The name query is this:</p>
  
  <pre><code>@NamedQuery (name = "Customer.getById", 
  query = "SELECT o FROM gnf.Customer o WHERE o.user = :id")
  </code></pre>
  
  <p>In the Customer.java class itself the relevant column is this one:</p>
  
  <pre><code>@ManyToOne (fetch = FetchType.LAZY)
  @JoinColumn (name = "user_id")
  private User         user;
  </code></pre>
  
  <p>Doing a quick check of my ERD the "id" column in my "customer" table has a data type of BIGINT.  However I'm not sure if that matters.  (PostgreSQL database by the way.)</p>
  
  <p>How can I fix this error?</p>