I encountered a strange problem while doing a supposedly simple Hibernate query. I defined 3 columns in the HQL, according to the Hibernate debug, the created SQL also contains 3 columns, but at calling query.list() Hibernate throws an exception saying that it is missing one column. Calling query.getReturnTypes revealed that the query expected a 4th column containing an integer. I am stuck, would welcome an ideas, or pointers on the topic
Here is the basic code:
The DB hierarchy is quite simple, a Person can have multiple Phones, and a PhoneBill is a specific phone's cost data for a given period (BillingPeriod object).
Originally posted by miguel lisboa:
just a guess:
looks like you'r translating from sql...
if you map Person and Phone as a parent/child relatioship your hql will be much simpler
take a look at docs that ship with install - there they have several parent/child examples
hope this helps
Yes, you are right, that the query is closer to SQL than to HQL, I need practice with it
Still, rewriting it did not help:
It seems that my Hibernate (2.1.8) has a bug evaluating queries containing complex aggregates, it creates the right SQL from the HQL statement, but at the same time it expects one more column returned than the actual number of them. Anyone had similar experiences ?
Too bad I cannot upgrade current in my project to 3.0