I have done something done with SQLQuery, whereby you throw a generic query at the database, and then you map the columns and types manually while looping through the results sets...
eg.
Code:
SQLQuery q=sess.createSQLQuery("select firstnm,lastnm,createdt from person_table");
Iterator itr=q.list().iterator();
Object obj[]=null;
while(itr!=null&&itr.hasNext())
{
col=(Object[])itr.next();
System.out.println("firstnm is col[0]:" + col[0]);
System.out.println("lastnm is col[1]" + col[1]);
System.out.println("createdt is col[2]" + col[2]);
}
But dynamically instantiating a new class that has all the get/set methods created for it, based on a query is not something I know about.
Guess you'd have to define and compile the class on the fly...not sure.
There is a concept that I read about called "4.4. Dynamic models" noted in the reference.pdf doc that allows you to save dynamically without having to use a POJO class. Also there is "Chapter 18. XML Mapping" (noted as being experimental).
Quote:
You can write queries that retrieve dom4j trees
from the database and have any modification you make to the tree automatically synchronized to the database.
Check out:
http://www.hibernate.org/hib_docs/v3/reference/en/pdf/hibernate_reference.pdf