title: Java JPA error; You have attempted to set a value of type class data expected type of int from query string
body: <p>I have error of java JPA project below. Could anyone help me? Thank you. </p>
  
  <p>Type Exception Report</p>
  
  <p><strong>Message</strong> You have attempted to set a value of type class data.CityMake for parameter cityMakeMakeID with expected type of int from query string Select f from Foodmodel f WHERE f.cityMakeMakeID = :cityMakeMakeID order by f.foodModelName.</p>
  
  <p><strong>Description</strong> The server encountered an unexpected condition that prevented it from fulfilling the request.</p>
  
  <p><strong>Exception</strong></p>
  
  <p>java.lang.IllegalArgumentException: You have attempted to set a value of type class data.CityMake for parameter cityMakeMakeID with expected type of int from query string Select f from Foodmodel f WHERE f.cityMakeMakeID = :cityMakeMakeID  order by f.foodModelName.</p>
  
  <p>org.eclipse.persistence.internal.jpa.QueryImpl.setParameterInternal(QueryImpl.java:933)</p>
  
  <p>org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:593)</p>
  
  <p>dao.FoodModelDAO.getModels(FoodModelDAO.java:69)</p>
  
  <p>servlets.StartServlet.processRequest(StartServlet.java:67)</p>
  
  <p>servlets.StartServlet.doGet(StartServlet.java:86)</p>
  
  <p>javax.servlet.http.HttpServlet.service(HttpServlet.java:635)</p>
  
  <p>javax.servlet.http.HttpServlet.service(HttpServlet.java:742)</p>
  
  <p>org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)</p>
  
  <p>Note The full stack trace of the root cause is available in the server logs.</p>
  
  <p>--------------------------------FoodModelDAO.java---------------------</p>
  
  <p>public class FoodModelDAO 
  {</p>
  
  <pre><code>  public static List&lt;Foodmodel&gt; getModels(int makeid)
    {
  
      CityMake make = CityMakeDAO.findMakeById(makeid);
  
      EntityManager em = DBUtil.getEmFactory().createEntityManager();
      String qString = "Select f from Foodmodel f " +
                       "WHERE f.cityMakeMakeID = :cityMakeMakeID  " +
                       "order by f.foodModelName";
  
      TypedQuery&lt;Foodmodel&gt; query = em.createQuery(qString, Foodmodel.class);
  
        query.setParameter("cityMakeMakeID", make );
  
      try
      {
          List&lt;Foodmodel&gt; models = query.getResultList();
          return models;
      }
  
      catch(NoResultException e) 
      {
          return new ArrayList&lt;Foodmodel&gt;();
      }
      finally 
      {
          em.close();
      }
    }
  </code></pre>
  
  <p>}</p>
  
  <p>---------------FoodModel.java post 4/2/2018-----------------------
      I have updated FoodModel post again.  </p>
  
  <pre><code>enter code here
  
  
  
  
  @Entity
  public class FoodModel {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long    foodModelId;
  private String  foodModelName;
  
  
  @OneToOne
  private CityMake cityMakeMakeID;
  
  public FoodModel() {
  
      foodModelName = "";
  
  }
  
  public FoodModel(Long m, String v, CityMake makeObj) {
      foodModelId = m;
      foodModelName = v;
      //citymake = makeObj;
      cityMakeMakeID = makeObj;
  }
  
  public Long getModelId() {
      return foodModelId;
  }
  
  public void setModelId(Long id) {
      foodModelId = id;
  }
  
  public String getModelName() {
      return  foodModelName;
  }
  
  public void setModelName(String value) {
      this.foodModelName = value;
  }
  
  public CityMake getMake() {
      //return citymake;
      return cityMakeMakeID;
  }
  
  public void setMake(CityMake make) {
      //this.citymake = make;
      this.cityMakeMakeID = make;
  
   }
  </code></pre>
  
  <p>}</p>