【发布时间】:2015-07-24 09:52:42
【问题描述】:
我正在执行这样的 HQL 查询:(hql 查询将是动态的,具有不同的列名、列数、数据类型)
Session session = getSession();
Query hqlQuery = session.createQuery("select a.id as Id, a.name as Name, a.description as Description, a.locationCountryId as LocationCountryId from AboutUsMaster as a");
hqlQuery.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
List<Map<String, String>> myMapList = hqlQuery.list();
for (Map<String, String> map : myMapList ){
System.out.println(map.toString());
}
输出:
{Name=Test About, LocationCountryId=1, Description=Description, Id=9}
在地图中,我想获得与我在查询中选择的顺序相同的顺序。
在查询中,我选择了id、name、description、locationCountryId,但在地图中我以不同的顺序获取条目。
那么如何得到与查询中指定的相同的顺序呢?
【问题讨论】:
-
什么版本的 Hibernate?