-->
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: Is it possible to convert native SQL into HQL?
PostPosted: Thu Jul 26, 2007 4:34 am 
Newbie

Joined: Thu Jul 26, 2007 3:01 am
Posts: 1
There are situations when we have complex SQL queries and we wish that it is possible to convert sql into hql using some tool or Hibernate API.

That can be time saving and efficient way for those who are relatively new to HQL/Hibernate.

1) Is there any tool that converts raw SQL into HQL?
2) Is there any Hibenate API using which we may create Query from raw SQL and then see the HQL generated by Hibernate, may be on debug console?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 8:36 am 
Regular
Regular

Joined: Sat Jan 22, 2005 6:57 pm
Posts: 50
Location: Chicago
I looked for this sorta thing a while back.

Unfortunately, to my knowledge, there is nothing available. You can use a session.createSQLQuery() and pass it your real query, but there is not anything that will then take that Query object and change it into HSQL.

Go ahead and write one and sell it and make money. :)

Dont forget to rate! :)


Top
 Profile  
 
 Post subject: HQL and SQL
PostPosted: Thu Jul 26, 2007 9:06 am 
Newbie

Joined: Tue Dec 06, 2005 10:13 am
Posts: 17
Why do you care so much of converting SQL to HQL?, Hibernate will convert them back to SQL anyway ...
Simply get Connection from Hibernate and run it using SQL. I do it with all my complex queries (It is a reports system, that somethimes runs about 10 queries in order to produce a single report).
When it comes to real complexity, for my opinion, it is better using SQL directly, especially if you need specific SQL server semantics like "if"/"case" conditions, or specific functions usage.


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.