I think you might be interested in looking at the AuDAO source code (you can “use” the part that generates DAO and Beans and writes code that does something similar - it's open source)
this library does exactly what you describe: 
However, I think that you can miss this, the advantage of using tools like Hibernate is a free database connection for the developer. You do not need to know all the dialects of the database; Hibernate does. This is convenient because either production servers work with DB2, Oracle, or MySQL, and our Junit tests use SQLite, which has a different syntax.
Good luck
aviad
source share