Hello,
A few comments:
1. One minor point: I think your bean is a persistent entity not a DAO. DAOs contain database access logic.
2. I believe a Hibernate SQL queries must be return all of the columns corresponding to the properties of the object. Since you SELECT does not return var3 you get this error "Invalid column name var3"
3. If you just want to populate a subset of the entity's properties you could use an HQL query that looks like this "select new Table(t.id, t.var1, t.var2) from Table t where ..". See
http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html#queryhql-select 4. Another option is to use lazy property fetching:
http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-fetching-lazyproperties However, are you sure that you really want to do this. If Table is mapped to the database but you only need to retrieve a subset of properties then perhaps
you should 5. Are you sure that you want to do this? Retrieving only a subset of an object's properties can be confusing unless you use option #4. Also, retrieving a non-persistent copy of your object (as your SQL query does or my HQL query in point #3 does ) can be confusing since updates to it will be ignored.
Sometimes it can be cleaner to create a DTO such as TableSummary that contains just the required properties and is not mapped to the database. It would be retrieved using "select new TableSummary(t.id, t.var1, t.var2) from Table t where .."
Chris