Dashboard > OpenSource Project > ... > 認識Relationships > Map
OpenSource Project Log In   View a printable version of the current page.
Map
Added by koji lin, last edited by koji lin on Oct 26, 2004  (view change)
Labels: 
(None)

Definition:

A map is a simple name-value pair list stored on a first rank collection.

Scenario:

Map Foo.getAges()   //  returns a collection of String name-value pairs

Hibernate Mapping

在hbm.xml中設定如下:

<class name="Foo" table="foo">
    ...
    <map role="ages">
        <key column="id"/>
        <index column="name" type="string"/>
        <element column="age" type="string"/>
    </map>
</class>

Table Schema

Foo
id
Ages    
id name age

A simple extra table, Ages, is used to store the name and age string-value pair. Note that the map needs its own identity column too: id

Bidirectionality:

Bidirectionality has no meaning for a map.

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.1.5a Build:#411 Mar 16, 2006) - Bug/feature request - Contact Administrators