Originally posted by taraka ninu:
1) am new to hibernate. can anybody tell me how to get Distinct records (in my case distinct column) using hibernate query???
ex : i want something like we get in SQL
Select distinct column1 from table
If you are using the Criteria object, a more appropriate way to do it is
Criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
If you are using HQL or SQL, you can simply specify "distinct" in your query as suggested.
Originally posted by taraka ninu:
2) is it possible to get only specific columns like in SQL query ?
ex : i want something like
Select column1 from table
Hibernate (well, Gavin King) says that the time required to get one column as opposed to 10 columns for a row is not significant. So, Hibernate chooses to retrieve all the columns in a row.
If you are going to use only a subset of columns of a table in your application all the time, you can always map only those columns in your HBM file.