问题
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