如何使用注释在休眠状态下映射“地图”?
使用注释如何将作为 String 的“Map”(Hashtable)的实体中的字段映射到给定对象?该对象已进行批注,并且其实例已存储在休眠数据库中。
我发现了使用简单键和值来定义地图的语法, 如下所示:
<class name="Foo" table="foo">
...
<map role="ages">
<key column="id"/>
<index column="name" type="string"/>
<element column="age" type="string"/>
</map>
</class>
奇怪的是,实体作为键,简单类型作为值,如下所示:
<class name="Foo" table="foo">
...
<map role="ages">
<key column="id"/>
<index-many-to-many column="person_id"
class="Person"/>
<element column="age" type="string"/>
</map>
</class>
<class name="Person" table="person">
...
<property name="name" column="name"
type="string"/>
</class>
但是我不知道如何为元素映射的简单键执行此操作,我也不知道如何使用注释来执行此操作。