I'm trying to use a native SQL query using session.createSQLQuery.
It works fine for me when I try and return a list of objects using
String sql = "SELECT {org.*} FROM organisational_unit org START WITH organisational_unit_id="+orgUnitId+" CONNECT BY PRIOR organisational_unit_id=orgunit_parent_id";
but if I try and return a column I get an SQLException: Invalid column name. I know that the query works as it runs directly against the database. The SQL string I'm using is:
String sql = "SELECT org.WORKFLOW_QUEUE_NAME as {org.queueName} FROM organisational_unit org START WITH organisational_unit_id="+orgUnitId+" CONNECT BY PRIOR organisational_unit_id=orgunit_parent_id";
List queues = getSession().createSQLQuery(sql, "org", OrgUnit.class).list();
Can anyone let me know if I'm doing something wrong here or if I'm missing something out.
Thanks
|