user973479
user973479

Reputation: 1659

Hibernate / Oracle 'with' clause / Native SQL

Is it possible to use the Oracle 'with' clause from hibernate?

I have the following basic example:

final String queryStr =
" with v_tbl as ( "+
" select distinct etc...";

final Query query = getSessionFactory().getCurrentSession().createQuery(queryStr);
final List results = query.list();

I get the following exception:

ERROR org.hibernate.hql.PARSER  - line 1:2: unexpected token: with

I read an article which suggested switching to:

<prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>

but that didn't seem to help.

Any suggestions?

fyi, I'm using Hibernate 3.6.7, Spring 3.0.6, Oracle 11g

Upvotes: 2

Views: 2020

Answers (1)

WeMakeSoftware
WeMakeSoftware

Reputation: 9162

You can use native sql query anytime

getSessionFactory().getCurrentSession().createSQLQuery(queryStr)

Upvotes: 6

Related Questions