I am using HQL to add a few fields from a table. Here is an example:
select (foo.valueA + foo.valueB + foo.valueC) from Foo foo where foo.bar.date = :date
I can then get the resulting value doing something like:
Code:
Double value = (Double)this.getSession().createQuery(queryString)
.setDate("date", bDate)
.uniqueResult();
If foo.valueA = 10 and foo.valueB = 15 and foo.valueC = 30 then this query returns 55 : excellent!
If foo.valueA = 10 and foo.valueB = 15 and foo.valueC = null then this query returns null and not 25: NOT excellent!
What I would hope is that in this second example the query would return the value '25' as that is the sum of those three fields as best can be determined. Is this type of behavior possible? Any help is appreciated.
Thanks,
Rob