-->
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.  [ 3 posts ] 
Author Message
 Post subject: Query Parser API
PostPosted: Fri Jul 25, 2008 2:48 am 
Newbie

Joined: Wed Jan 02, 2008 8:16 am
Posts: 3
Hi,

We have a legacy application which works with Postgres database. It has sql queries which use postgres specific functions like date_part and date_trunc in the query select clause, where clause etc

Now the target is to port this application to Oracle and potentially SQL server.
This application uses JDBC and does not use Hibernate.

Now what we plan to do is instead of changing each query or putting conditions for each query we would like to transform/translate that query at runtime. So before execution, the query will be intercepted and transformed to support the target Dialect.

Does Hibernate provide API for SQL query parsing and generate a query model having methods like getWhereClause, getFromClause etc for DML's.

And then is there a possibility to transform that query to Oracle Dialect compliant query.

Regards
Piyush


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 4:27 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
If you use Hibernate, your application will have a dialect that will take your queries and translate them into the appropriate database SQL at runtime. This is done through the dialect setting in the hibernate configuration file.

From there, you can actually send native SQL through the Hibernate Session if need be.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Query Parser API
PostPosted: Sun Jul 27, 2008 7:14 am 
Newbie

Joined: Wed Jan 02, 2008 8:16 am
Posts: 3
So does it mean that following query will be translated automatically into an Oracle dialect query at runtime

Example of postgres query
String query = "SELECT date_part('day', TIMESTAMP '2001-02-16 20:38:40')"

Possibly converted oracle query
select to_char(to_date( '2001-02-16 20:38:40' ,'YYYY-MM-DD HH:MI:SS'),'DD') from dual

Is this a possibility

If yes than please post some sample code on how to achieve this

Regards
Piyush


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