[jboss-user] [EJB 3.0] - How to mix integer and double in the ejbql
r_q_d
do-not-reply at jboss.com
Mon Jan 26 10:19:56 EST 2009
I have a entity bean like this:
PlayScoreBean
| public class PlayScoreBean implements java.io.Serializable{
| ...
| private Integer rawScore;
| public Integer getRawScore() {
| return rawScore;
| }
|
| public void setRawScore(Integer rawScore) {
| this.rawScore=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?
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4204733#4204733
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4204733
More information about the jboss-user
mailing list