-->
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: How to use NHibernate.Hql.Classic.ClauseParser class?
PostPosted: Fri Mar 16, 2007 5:44 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Hibernate version: 1.20CR1

We need to do HQL parsing because we want all of our data access to be HQL-based, yet we need support for programatically modifying the SELECT clause and managing criteria by programatically modifying the WHERE clause. We also have our own framework to dynamically generate "view" classes from HQL queries to flatten the query results into a single class for easy binding, and to support that we parse the HQL to get the driving entity, joined entities, and properties through which they are joined out of the FROM clause.

We created our own HQL parser, and it works for the simple-structured queries we have now, but our parser is a lame hack and would surely choke on more complex queries. We don't want to be in the HQL parsing business, so we want to use what NHibernate already uses internally.

Can anyone provide examples of using the NHibernate.Hql.Classic.ClauseParser class? The API documentation says it parses HQL query text into its constituent clauses, but does not say how to do that. It only has methods Start(), Token() and End(). Our lame homebrew HQL parser has the API we want:

Code:
public virtual bool ParseClauses(
   string hqlQueryText,
   out string selectClause,
   out string fromClause,
   out string whereClause,
   out string groupByClause,
   out string havingClause,
   out string orderByClause,
   bool throwExceptionOnError)
{
    // returns true if parsing errors occur
    // and throwExceptionOnError is false
   ...
}


How do we use NHibernate.Hql.Classic.ClauseParser so that our ParseClauses() method can become a thin, convenient API and just forward to the ClauseParser to do the work reliably?


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.