0

A entity containing a HashMap (annotated with ElementCollection) will be persisted using Eclipse Link / JPA.

By using the following JPQL query the HashMap should be retrivied now:

SELECT t.myMap FROM myEntity t WHERE t.id = :id"

Unfortunately the result is not the Map again, but a list of Strings which are (only) the values of the HashMap.

How can I get the HashMap as a single result?

Any help is appreciated.

4

1 回答 1

0

你不能。您要求的不是实体中的集合,而是联接中的元素。您可能会得到的最好的结果是查询实体并使用它的 getMyMap() 来获取您所追求的集合

于 2013-03-20T12:37:06.397 回答