I am building a JDBC adapter. This adapter would have to take the SQL to be executed in the form of, say, fields to be retrieved, join condition, table name etc. I was not sure if all the constraints specified by the user can be adequately represented in ANSI SQL so as to make it DB independent.
Can I leverage Hibernate to delegate this dirty work to it and keep our code clean? Would it be possible for me to pass the query in some standard form (XML or anything else) and get back the native SQL string for that DB from hibernate. I can then use this native SQL string and execute it using JDBC.
I cannot use Hibernate for the entire task as the SQL query to be executed will not be available until runtime. Therefore I would have to generate the classes to map the query dynamically. Also I need to manually work on the ResultSet to iterate over it in some specific fashion.
The questions I have are:
1. Can I pass the query in some standard form (XML or anything else) and get back the native SQL string for that DB from Hibernate? This would be my ideal scenario because I can then use this as a Query Builder engine for other database adapters.
2. Can I pass the query in some standard form (XML or anything else) and get back the ResultSet after executing the query on the database? This is a not so ideal scenario but I can still make this work.
I am also open to suggestions about any other way of achieving this task.
Any help that you guys can provide will be extremely appreciated.
|