Hi,
You cannot start an HQL query with 'WITH'.
Here is an extract from HQL grammar,
queryRule : selectFrom (whereClause)? (groupByClause)? (orderByClause)? ; selectFrom! : (s:selectClause)? (f:fromClause)? { // If there was no FROM clause and this is a filter query, create a from clause. Otherwise, throw // an exception because non-filter queries must have a FROM clause. if (#f == null) { if (filter) { #f = #([FROM,"{filter-implied FROM}"]); } else throw new SemanticException("FROM expected (non-filter queries must contain a FROM clause)") ; } // Create an artificial token so the 'FROM' can be placed // before the SELECT in the tree to make tree processing // simpler. #selectFrom = #([SELECT_FROM,"SELECT_FROM"],f,s); } ;
>>>If a oracle query which is starting with WITH clause need to be converted in hql then how it can be done?
As far as I know, you can't rewrite it 'as-is' in HQL.
However, you can do the following.
i) Map an entity to query names created using 'WITH'. From here on, it is plain HQL.
ii) Use createSQLQuery() and then addEntity() to it so as to work with objects.
------------------------------------------
Rate the reply if you find it helpful
|