是否可以映射地图< String,List< Entity>>在JPA? [英] Is it possible to map a map<String,List<Entity>> in JPA?

查看:148
本文介绍了是否可以映射地图< String,List< Entity>>在JPA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想是否使用地图 Map< String,List< Entity>> Map< Long,List< Entity> > 它会帮助我解决一些问题,但我找不到任何映射这种地图的例子。

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.

我的问题是,有可能在JPA标准中进行这种映射,我应该使用什么样的注释?

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

推荐答案

是,可以创建其中任何一个地图。为什么不试试并回答你自己的问题呢?它会比在这里被动地询问要快。

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.

对于JPA,我建议使用比Map更好的抽象来保存数据。这对我来说太通用了。这可能就是你想要的,但是JPA ORM应该映射到比集合更强大的对象模型。

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.

这篇关于是否可以映射地图&lt; String,List&lt; Entity&gt;&gt;在JPA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆