-->
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.  [ 5 posts ] 
Author Message
 Post subject: HQL Parser
PostPosted: Wed Apr 14, 2004 11:15 am 
Newbie

Joined: Tue Apr 13, 2004 11:28 am
Posts: 2
Location: Brazil
Hello all,

Currently I'm starting to study hibernate and trying to build a generic DAO on top of it. One of the methods of this DAO is responsible for looking up objects. It gets a simple JavaBean as a parameter, based on the class of this bean, gets a HQL query from a property file, uses bean's properties as parameters for this query and executes this query using a hibernate session. This is simple and is working well.

My problem is that I'm trying to go a little futher. I'm trying to put a flag ( e.g. {} ) on these queries to mark some parts of the where clause as optional. These parts would be used if corresponding properties are set in the bean that is received as method's parameter.

For example, I would like to have something like this in my property file:

mypackage.MyJavaBean=from Item item where item.description like :searchString
and { item.date > :minDate }

When the generic method responsible for executing queries receives an instance of mypackage.MyJavaBean as parameter it has to get this query from the property file and, if minDate property of that bean has a value other than null, item.date > :minDate is used in the query. Otherwise that part of the query is cropped.

To do something like that I have do build a parser... I was thinking of using hibernate's parser instead. As far as I could see it seems that it is suffering some modifications, isn't it? Does anyone has other ideas?

Thanks a lot and sorry about this long mail.

Best regards,

F


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 14, 2004 11:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Don't try to reuse the HQL parser, at least not until it gets rewritten.


Top
 Profile  
 
 Post subject: Parser grammar?
PostPosted: Wed Apr 14, 2004 5:18 pm 
Newbie

Joined: Fri Feb 27, 2004 6:17 pm
Posts: 11
Are you going to be posting the grammar in advance of the parser?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 14, 2004 5:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
may i suggest to use the Criteria API for such dynamic construction of queries ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2004 5:30 pm 
Newbie

Joined: Tue Apr 13, 2004 11:28 am
Posts: 2
Location: Brazil
Hello everybody,

Thanks a lot for your answers! I'll think more about my problem!

Best wishes,

F


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