-->
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.  [ 1 post ] 
Author Message
 Post subject: modifying HQL queries using the AST
PostPosted: Thu Aug 03, 2006 12:12 pm 
Newbie

Joined: Thu Aug 03, 2006 11:40 am
Posts: 4
hi everyone,

I'm trying to programmatically manipulate an HQL query. for example, given an HQL query, I'd like to produce a second query that counts the result set size of the first query.

I know that Criteria objects are an effective way to accomplish dynamically constructed queries, but please believe that starting with HQL instead is desirable in my circumstances.

The strategy I thought to use was:

1. use HqlParser to get an AST for the query source
2. manipulate the AST (add a select->count->pk subtree, for example)
3. regenerate HQL from the modified syntax tree.

it currently doesn't look like there's a tree walk algorithm that generates HQL from HQL. am I wrong about this? it seemed to me like someone else might have tried to do this already. any pointers or other suggestions?

i don't have significant ANTLR skills, so I'd like to avoid writing a HQL->HQL tree parser if possible.

thanks
jt


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

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.