0 Replies Latest reply on Jan 26, 2009 10:19 AM by Quande Ren

    How to mix integer and double in the ejbql

    Quande Ren Newbie

      I have a entity bean like this:


      public class PlayScoreBean implements java.io.Serializable{
       private Integer rawScore;
       public Integer getRawScore() {
       return rawScore;
       public void setRawScore(Integer rawScore) {

      then an ejbql here:

       Double mean=...
       query = entityManager.createQuery(
       "select sum((c.rawScore-:mean)*(c.rawScore-:mean)) "
       + " from PlayScoreBean as c ");
       query.setParameter("mean", mean);
       Double standardDeviation=(Double) query.getSingleResult();

      the rawScore is an Integer , but I am trying to calculate a double value from it. I got this error:

      [IntegerType] could not bind value '150.14285714285714' to pa
      rameter: 1; java.lang.Double
      [STDERR] java.lang.ClassCastException: java.lang.Double

      It complains that I cannot bind a double value to integer value.

      If I change the rawScore in the entity bean from Integer to Double, then the query works OK, But that is not what I want.

      Anybody knows how to mix the integer with double, or is there any number converter functions to call? Anybody can help me to make this work?