Hi,
I have trouble using properties (instead of column names) in the WHERE clause of a SQLQuery.
For example:
Code:
SQLQuery q = session.createSQLQuery("SELECT {insect.*} FROM insect {insect} WHERE {insect}.numberOfLegs=6").addEntity("insect", Insect.class);
This results in "Unknown column 'insect.numberOfLegs' in 'where clause'".
The column name in the database is number_of_legs.
I tried to inject the alias name using "WHERE {insect.numberOfLegs}=6" but then the database also complains with something like: "Unknown column 'number6_1093_0_' in 'where clause'". I guess this is because MySQL does not allow aliases in the WHERE clause (
http://dev.mysql.com/doc/refman/5.0/en/problems-with-alias.html).
Is it at all possible to use properties instead of column names in the WHERE clause?
Hibernate version: 3.3.1 GA