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.  [ 13 posts ] 
Author Message
 Post subject: parsing HQL statement
PostPosted: Wed Nov 29, 2006 6:32 am 
Newbie

Joined: Fri Nov 24, 2006 6:33 am
Posts: 11
I try to make a framework to manage distributed on persistant objects. The idea is to use interface to link objects, and use a specific component to create true object or proxy on distant object. To implement persistance facility, i want to use NHibernate.
The problem is that when a user try to make an HQL request on some object, i need to parse the request in HQL, suppress access on proxies objects and give to NHibernate the new modified HQL request to NHibernate.
My question is: how can i parse manually an HQL request, and manipulate the syntaxic tree of an HQL request?
I see that QueryTranslator can compile an HQL expression (nothing is write in documentation), is it the good choice? how can I use it?

An sorry for my english...I'm french


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 7:16 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Don't know it this is what you need. This let's you access at the native SQL, not the HQL:

org.hibernate.Interceptor.onPrepareStatement(String sql)

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 9:06 am 
Newbie

Joined: Fri Nov 24, 2006 6:33 am
Posts: 11
No, i want to have an object model of an HQL request, like a tree of IParser objects (see NHibernate.Hql.ClauseParser for example)

I want to know How to use this tree of tokens language objects, in order to change the tree and regenerating a new transformed HQL request


Top
 Profile  
 
 Post subject: ohé?
PostPosted: Fri Dec 01, 2006 3:00 pm 
Newbie

Joined: Fri Nov 24, 2006 6:33 am
Posts: 11
ohé? is there anybody here which can give me a response for my problem?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 01, 2006 4:02 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
The closest thing that exist is QueryTransalator, and it is definately not an AST.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 02, 2006 10:21 am 
Newbie

Joined: Fri Nov 24, 2006 6:33 am
Posts: 11
what do you mean, when you said "AST"?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 02, 2006 1:07 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Abstract Syntax Tree.
The object model for the HQL


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 7:03 am 
Newbie

Joined: Fri Nov 24, 2006 6:33 am
Posts: 11
OK, queryTranslator is not an AST, but how can I use it? is it possible to create it from an string HQL, modify it (explicitely navigate in IParser sub-objects and casting it), an ask for th new HQL request? can you give a (short) example? (for example, suppress one test in a where clause)


Top
 Profile  
 
 Post subject: any information?
PostPosted: Thu Dec 07, 2006 5:44 am 
Newbie

Joined: Fri Nov 24, 2006 6:33 am
Posts: 11
is it possible to have a response, even like 'I don't know' from a contributor?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 6:24 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
HQL parsing code was not intended to be used outside of NHibernate, so you'll have to dig into it and see for yourself what can be done.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 3:23 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Off the top of my head, I would say that it would be easier to take the Antlar code from Hibernate 3.0, generate C# AST, and work with that.
On the end, though, you'll need to return it to HQL string to send it to NH again, since it doesn't understand it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 21, 2006 10:16 am 
Newbie

Joined: Fri Nov 24, 2006 6:33 am
Posts: 11
do you mean I need to convert java code of Hibernate 3.0?

I try to execute :

IParser parser = new PreprocessingParser(new Hashtable());
QueryTranslator translator=new QueryTranslator(factory,"requete HQL",new Hashtable());
ParserHelper.Parse(parser,"requete HQL" ,ParserHelper.HqlSeparators, translator);

using debugger, and I see that a lot of internal variables (like child in all clauseParser) may be interesting to use (to get all sub-clause and theirs propeties) but actually it's not possible because all fields are declared private

May be it was more interesting to just make theirs fields protected (and let's a good developer make it's own parser) ...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 22, 2006 11:37 am 
Newbie

Joined: Thu Dec 21, 2006 5:48 pm
Posts: 4
Do you need to send the query over the network? Does it need to be HQL? Would it be possible to parse the HQL and create criteria with it by creating EqExpression, AndExpression, etc. yourself and then using this to query? After looking at the code, it looks like this is something that is being considered for the HQL parser that is built in.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.