Hibernate中的Multimap [英] Multimap in Hibernate

查看:110
本文介绍了Hibernate中的Multimap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个将条目存储为键值对的集合(所以我可以通过键查找值),但是我需要一个允许多个值使用hibernate共享同一个键的集合


对于一个键,具有多个值的映射被称为多映射 - 在Apache commons库中有一个实现。 Hibernate不直接支持这种集合,但可以通过实现 UserCollectionType 接口来相对简单地扩展它。这篇博客文章描述了如何详细介绍。


I need a collection that stores entries as key-value pairs (so I can look up values by a key), but I need one that allows multiple values to share the same key using hibernate

解决方案

A map with multiple values for one key is known as a multimap - there's an implementation in the Apache commons library. Hibernate does not support this kind of collection directly, but it can be extended to do so relatively easily by implementing the UserCollectionType interface. This blog article describes how to do it in detail.

这篇关于Hibernate中的Multimap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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