Sep 29, 2008 - 03:31 PM
The hibernate queries I use reference a class, and we have hibernate mapping (xml) files that map variables inside a class to a column in the table
It looks like you got normal sql, I wonder if you need to use it as Hibernate expects?
I do not use formula's like you do as Ive coded it with the class querying. XML files simply used to map (*.hbm.xml)
Sep 30, 2008 - 02:41 AM
As far as I've read formulas have to be sql, hql won't work there.
But I figured out what the problem was. In this particular case I had created a sql query instead of using the hql, in order to get a particular result set of the user class that this formula is part of. So the sql was not adding the AnswersCount "virtual" property and that was why it was giving an error.
Nov 27, 2009 - 11:55 PM
mapping file, so it looks as if nhibernate ignores
the formula when you use CreateSqlQuery but then tries to access the derived column from the result set which creates the error. This seems to be a bug in Nhibernate and I haven't found a workaround.
To avoid this error, as dustyPuppy said, you must try to use a normal CreateQuery instead of CreateSQLQuery or remove the properties with the formula attribute in your mapping file, as there is not currently a patch for this issue.