Oracle cannot use aliases in where clause, but HQL generate it.
EXAMPLE FROM
HIBERNATE-REFERENCE IS NOT OK
Code:
String sql = "select cat.originalId as {cat.id}, " +
"cat.mateid as {cat.mate}, cat.sex as {cat.sex}, " +
"cat.weight*10 as {cat.weight}, cat.name as {cat.name} " +
"from cat_log cat where {cat.mate} = :catId"
List loggedCats = sess.createSQLQuery(sql)
.addEntity("cat", Cat.class)
.setLong("catId", catId)
.list();
Hibernate version: 3.0.5
Code between sessionFactory.openSession() and session.close():Code:
SQLQuery sq=session.createSQLQuery("Select a.algoritmus_id as {a.id}, a.algoritmus as {a.description} From MBO_algoritmus where {a.description} like ?");
sq.setString(0,"%a%");
sq.addEntity("a",Algorithm.class);
sq.list();
Name and version of the database you are using: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.1.0
The generated SQL (show_sql=true):Hibernate: Select a.algoritmus_id as Algoritmus1_0_, a.algoritmus as algoritmus0_0_ From MBO_algoritmus where algoritmus0_0_ like ?
WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 904, SQLState: 42000
ERROR [org.hibernate.util.JDBCExceptionReporter] - ORA-00904: "ALGORITMUS0_0_": invalid identifier
[/code]