[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Buy SSL certificates today and secure your website. Visit: http://sslstar.com/
Sam Doder wrote:
I am wondering if their is any easy way to convert from hibernate queries to JDBC queries and visa versa?
Without have to create my own function that converts it.
Is their any function in Hibernate that allows you to take a hibernate query object and convert it to a jdbc sql statement or result set?
Like taking a Criteria Object and turning it into a PreparedStatment JDBC object ? And visa versa
Going the otherway you are probably on your own. JDBC code will contain SQL, there is no SQL parsing element in Hibernate so you can't re-use their code. And SQL can contain way more than HQL or Criteria queries contain. There are Java SQL Parsers out there but I'm not sure how well they will support vendor specific SQL.
But My last resort was to go thru the source. I don't want to have to modify any source or anything.
Their should be away to get the underlying jdbc query for the Critera Object.
Ok , so I found that in hibernate the Query.getQueryString() ...
...but how do you get a Query Object from a Criteria Object?
Each of their nuggets of wisdom contracted to a sound bite: Joshua Bloch: Write Lots of Code; Chet Haase: Don't Put Your Entire Application in One Method; Masood Mortazavi: Start Simple and Keep Learning; Cay Horstmann: First, Don't Panic