title: JPA / JPQL Query error
body: <p>i am trying to retrieve a set of results from  a database ( 13 marks ) there will only ever be 1 row called, i then want to average the 13 results in the query and then return the value </p>
  
  <p>i have created the query :</p>
  
  <pre><code>public String markingAvg(Marking id) {
      System.out.println("id = " + id);
      Query m = em.createQuery("SELECT (m.markSectionOne + m.markSectionTwo + m.markSectionThree + m.markSectionFour + m.markSectionFive + m.markSectionSix + m.markSectionSeven + m.markSectionEight + m.markSectionNine + m.markSectionTen + m.markSectionEleven + m.markSectionTwelve + m.markSectionThirteen) FROM MARKING m WHERE m.id = :id", Double.class);
      m.setParameter("id", id);
  
      Object avg = m.getSingleResult();
      return null;
  }
  </code></pre>
  
  <p>not sure if this is right so any advice would be welcome</p>
  
  <p>i call it via a test button :</p>
  
  <p>init</p>
  
  <pre><code>            String marking_id = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("edit_id");
      System.out.println(marking_id);
      if (marking_id != null) {
          this.markToEdit = this.markingFacade.find(Long.parseLong(marking_id));
      }
  
      marksByMarkingId = markingFacade.markingAvg(markToEdit);
  }
  </code></pre>
  
  <p>the button calls :</p>
  
  <pre><code>public void markSearch() {
      searchAvgResults = markingFacade.markingAvg(markToEdit);
  
  }
  </code></pre>
  
  <p>however on initalisation of ( the marksByMarkingId is done in init) </p>
  
  <p>i get the error </p>
  
  <pre><code>java.lang.IllegalArgumentException: You have attempted to set a value of type class sws.entities.Marking for parameter id with expected type of class java.lang.Long from query string SELECT (m.markSectionOne + m.markSectionTwo + m.markSectionThree + m.markSectionFour + m.markSectionFive + m.markSectionSix + m.markSectionSeven + m.markSectionEight + m.markSectionNine + m.markSectionTen + m.markSectionEleven + m.markSectionTwelve + m.markSectionThirteen) FROM MARKING m WHERE m.id = :id.
  </code></pre>
  
  <p>any ideas guys or does anyone have a better way of doing this ?</p>
  
  <p>Thanks Guys</p>
  
  <p>Here is the marking entity</p>
  
  <p>@Entity(name = "MARKING")
  public class Marking implements Serializable {</p>
  
  <pre><code>private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  
  @ManyToOne
  private Person marker;
  
  @ManyToOne
  private Project project;
  
  // @ManyToOne
  //  private Project project;
  //@ManyToMany(mappedBy = "title")
  //private Project projectBeMarked;
  ;
  
  private String markingCompleted, thirdMarker, plagorism, markSectionOne, markSectionTwo, markSectionThree, markSectionFour,
          markSectionFive, markSectionSix, markSectionSeven, markSectionEight,
          markSectionNine, markSectionTen, markSectionEleven, markSectionTwelve, markSectionThirteen, markAdjust, overalMark;
  </code></pre>
  
  <p>what i want to do is retrieve an id (which i do by passing it from the web address) and then want to average the markSectionOne - Thirteen </p>
  
  <p>getter / setters for id</p>
  
  <pre><code> /**
       *
       * @return
       */
      public Long getId() {
          return id;
      }
  
      /**
       *
       * @param id
       */
      public void setId(Long id) {
          this.id = id;
      }
  </code></pre>
  
  <p>Now fixed thanks to a great guy on here</p>
  
  <p>however, when i press the test button to run the query i get the following error in the console</p>
  
  <pre><code>Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
  Internal Exception: java.sql.SQLSyntaxErrorException: The '+' operator with a left operand type of 'VARCHAR' and a right operand type of 'VARCHAR' is not supported.
  Error Code: -1
  Call: SELECT (MARKSECTIONONE + (MARKSECTIONTWO + (MARKSECTIONTHREE + (MARKSECTIONFOUR + (MARKSECTIONFIVE + (MARKSECTIONSIX + (MARKSECTIONSEVEN + (MARKSECTIONEIGHT + (MARKSECTIONNINE + (MARKSECTIONTEN + (MARKSECTIONELEVEN + (MARKSECTIONTWELVE + MARKSECTIONTHIRTEEN)))))))))))) FROM MARKING WHERE (ID = 48)
  Query: ReportQuery(referenceClass=Marking sql="SELECT (MARKSECTIONONE + (MARKSECTIONTWO + (MARKSECTIONTHREE + (MARKSECTIONFOUR + (MARKSECTIONFIVE + (MARKSECTIONSIX + (MARKSECTIONSEVEN + (MARKSECTIONEIGHT + (MARKSECTIONNINE + (MARKSECTIONTEN + (MARKSECTIONELEVEN + (MARKSECTIONTWELVE + MARKSECTIONTHIRTEEN)))))))))))) FROM MARKING WHERE (ID = ?)")
  </code></pre>
  
  <p>Currently getting the error</p>
  
  <pre><code>Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
  Internal Exception: java.sql.SQLSyntaxErrorException: TYPE 'UNSIGNED' does not exist.
  Error Code: -1
  Call: SELECT (CAST(MARKSECTIONONE AS UNSIGNED) + (CAST(MARKSECTIONTWO AS UNSIGNED) + (CAST(MARKSECTIONTHREE AS UNSIGNED) + (CAST(MARKSECTIONFOUR AS UNSIGNED) + (CAST(MARKSECTIONFIVE AS UNSIGNED) + (CAST(MARKSECTIONSIX AS UNSIGNED) + (CAST(MARKSECTIONSEVEN AS UNSIGNED) + (CAST(MARKSECTIONEIGHT AS UNSIGNED) + (CAST(MARKSECTIONNINE AS UNSIGNED) + (CAST(MARKSECTIONTEN AS UNSIGNED) + (CAST(MARKSECTIONELEVEN AS UNSIGNED) + (CAST(MARKSECTIONTWELVE AS UNSIGNED) + CAST(MARKSECTIONTHIRTEEN AS UNSIGNED))))))))))))) FROM MARKING WHERE (ID = 48)
  Query: ReportQuery(referenceClass=Marking sql="SELECT (CAST(MARKSECTIONONE AS UNSIGNED) + (CAST(MARKSECTIONTWO AS UNSIGNED) + (CAST(MARKSECTIONTHREE AS UNSIGNED) + (CAST(MARKSECTIONFOUR AS UNSIGNED) + (CAST(MARKSECTIONFIVE AS UNSIGNED) + (CAST(MARKSECTIONSIX AS UNSIGNED) + (CAST(MARKSECTIONSEVEN AS UNSIGNED) + (CAST(MARKSECTIONEIGHT AS UNSIGNED) + (CAST(MARKSECTIONNINE AS UNSIGNED) + (CAST(MARKSECTIONTEN AS UNSIGNED) + (CAST(MARKSECTIONELEVEN AS UNSIGNED) + (CAST(MARKSECTIONTWELVE AS UNSIGNED) + CAST(MARKSECTIONTHIRTEEN AS UNSIGNED))))))))))))) FROM MARKING WHERE (ID = ?)")
  </code></pre>
  
  <p>on the query :</p>
  
  <pre><code>public String markingAvg(Marking id) {
      System.out.println("In MarkingAvg");
      System.out.println("id = " + id);
      System.out.println("id =" + id.getId());
      Query m = em.createQuery("SELECT (CAST(m.markSectionOne AS UNSIGNED) + CAST(m.markSectionTwo AS UNSIGNED) + CAST(m.markSectionThree AS UNSIGNED) + CAST(m.markSectionFour AS UNSIGNED) + CAST(m.markSectionFive AS UNSIGNED) + CAST(m.markSectionSix AS UNSIGNED) + CAST(m.markSectionSeven AS UNSIGNED) + CAST(m.markSectionEight AS UNSIGNED) + CAST(m.markSectionNine AS UNSIGNED) + CAST(m.markSectionTen AS UNSIGNED) + CAST(m.markSectionEleven AS UNSIGNED) + CAST(m.markSectionTwelve AS UNSIGNED) + CAST(m.markSectionThirteen AS UNSIGNED)) FROM MARKING m WHERE m.id = :id", Double.class);
      m.setParameter("id", id.getId()); // Note the getId()
  
      Object avg = m.getSingleResult();
      return null; // Do you really want to be returning null here?
  }
  </code></pre>