我们有一个包含如下数据的表
id entity_type_id entity_id 1 1 1234 2 1 2356 3 1 7896 4 1 4321 5 2 1234 6 2 9876 7 2 5289 8 2 4568
And I wrote query as follow to get data. How can I modify this query to return it as list of entitiyIds as value and entityTypeId as key.
<query name="getAllEntities">
<![CDATA[
SELECT e.entity_type_id, e.entity_id from entity as e
]]>
</query>
最佳答案
类似下面的内容
<query name="getAllEntities">
<![CDATA[
SELECT new Map(e.entity_type_id as et_id, e.entity_id as e_id) from entity as e
]]>
</query>
引用this了解更多详情
关于java - hibernate : Resultset mapping in to Map<EntityTypeId, 列表 <EntitiyIds>>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32859491/