-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: problem to write a query with WITH clause
PostPosted: Thu May 10, 2007 2:04 am 
Newbie

Joined: Thu Apr 19, 2007 12:34 am
Posts: 8
Is it posible to start a hql query with a WITH clause of oracle.

If a oracle query which is starting with WITH clause need to be converted in hql then how it can be done?

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 5:07 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
Here is what you can do with HQL: http://www.hibernate.org/hib_docs/refer ... ryhql.html
You can't do much else with it.

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 10, 2007 9:46 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 11, 2007 12:54 am 
Newbie

Joined: Thu Apr 19, 2007 12:34 am
Posts: 8
hi

thanx for the reply.i will try it.is it posible to write an inline view in HQL??


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 11, 2007 7:55 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
>>> is it posible to write an inline view in HQL??
NO.
HQL subqueries may occur only in the select or where clauses.
So, we cannot have inline views in HQL.

----------------------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 5:02 am 
Newbie

Joined: Thu Apr 19, 2007 12:34 am
Posts: 8
thanx a lot.how to call a oracle function from hibernate hql query??thanks in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.