tags:

views:

127

answers:

1

Any suggestion how to fix this error? (I'd rather not create an sql view to skirt the issue with the sum aggregate)

"Can't extract the type of one parameter of a HQL function: expression->{TreatmentTime}; check aliases. [select new TherapyMinutesDisciplineByDayDTO( sum(TreatmentTime), 2.0, 3.0, t.TreatmentDate, p.LastName, d.Description ) from TherapyMinutesModule.TherapySession t join t._Patient p join t._Discipline d group by t.TreatmentDate, p.LastName, d.Description]"

Here's the hql:

                    c.HSQL = "select"
                     + " new TherapyMinutesDisciplineByDayDTO( sum(TreatmentTime), 2.0, 3.0, t.TreatmentDate, p.LastName, d.Description )"
                     + " from TherapySession t"
                     + " join t._Patient p"
                     + " join t._Discipline d"
                     + " group by t.TreatmentDate, p.LastName, d.Description"
+1  A: 

t.TreatmentTime?


Edit:

From comments below since my answer wasn't clear at all (sorry)

replace:

sum(TreatmentTime)

with

sum(t.TreatmentTime)
eyston
I need the sum of the times.
Jay
yah, but isn't TreatmentTime a member of TherapySession?
eyston
Imagine the SQL you would write ... select t.TreatmentDate, sum(t.TreatmentTime) from TherapySession t group by t.TreatmentDate ... right? (ignoring the patient / discipline stuff atm).
eyston
That's the correct sql. I think it's trying to do it but can't figure out the data type of the sum() aggregate function. If I do it without the sum it works just fine. I could move the sum to a view but I'd prefer to avoid that hack if possible. The database already has too much cruft in it.
Jay
You have sum(TreatmentTime) instead of sum(t.TreatmentTime) is what I'm saying.
eyston
You are the man! :)
Jay
Sorry for the cryptic original answer. I wasn't 100% sure that was right, so I didn't want to proclaim too strongly. I updated the answer for anyone else who comes here.
eyston