wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes get a sql query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "get a sql query" Watch "get a sql query" New topic

get a sql query

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1072
i need to get a sql query of a given Hql query.how can i do that?
when i am running a debugging it gives error at line "query.list ".
so i need to convert my HQL to sql .then i can find the error?
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

The error is unlikely to be a SQL error, unless there is a bug in whichever dialect you are using. Its more likely an HQL error. Can you post the stacktrace?

For reference, the hibernate.show_sql property will log the SQL hibernate generates.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
vishwa venkat
Ranch Hand

Joined: Nov 22, 2003
Posts: 185
did you try setting show_sql property in hibernate config and able to see the sql that it generated?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

When SQL gets generated, you can usually see it in the log file output. You can copy and paste the SQL into a database console window or something and execute the SQL and see how well it works.

If you're converting SQL to HQL, remember that HQL is object centric. You won't have primary keys, but your objects should have identifiers or ids.

-Cameron McKenzie
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: get a sql query
Similar Threads
hibernate left join not working
Stored Procedure inside HQL query?
How to Convert HQL to SQL Query
hibernate undefined alias : 1 error
Hibernate 3.0 Questions