I have a query of this nature
String query = select column1, group by column2 from table1 ...
//What should I write to just get column1 from the query.
getSession().createQuery(query).list();
How do I get just columne1 list from the query.
With hibernate HQL/JPQL queries you don't get get columns. You get objects and their properties. So:
String query = "SELECT yourEntity.property1 FROM yourEntity .....";
Then the list()
will return a List<Foo>
, where Foo
is the type of property1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.