Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.8
Name and version of the database you are using: MySQL 4.1.9
When using a formula of the following variety:
Code:
formula="( SELECT t.attr1 FROM Table t ORDER BY t.attr2 DESC LIMIT 1 )"
Hibernate prefixes the tokens DESC and LIMIT with a table alias in the generated SQL statement. It does recognize correctly though that ORDER and BY (and SELECT, etc) are SQL syntax tokens.
The generated SQL looks like:
Code:
SELECT t1_.id, t1_.a1, t1_.a2, ..., (SELECT t2_.attr1 FROM Table t2_ ORDER BY t.attr2 t2_.DESC t2_.LIMIT 1), t1_.aN FROM Table t1_;
I am not sure where exaclty the bug lies but I though I'd point it out so that someone who knows better can fix it.
Regards,
Giorgos