Is it possible to map a map<String,List<Entity>> in JPA?

本小妞迷上赌 提交于 2019-12-22 08:52:00

问题


I'm thinking if i use maps like Map<String,List<Entity>> or Map<Long,List<Entity>> it will help me with a few things, but I couldn't find any example to map that kind of map.

My question is, is it possible to do that kind of mapping in JPA standards, and what kind of annotation I should use?


回答1:


Yes, it's possible to create either of those Maps. Why not try it and answer your own question? It would be faster than passively asking here.

As for JPA, I would suggest a better abstraction than a Map for holding onto that data. This feels too generic for me. That might be what you're going for, but JPA ORM ought to map to a more robust object model than collections.



来源:https://stackoverflow.com/questions/9784101/is-it-possible-to-map-a-mapstring-listentity-in-jpa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!