开发者

mapping a java map to db table using orm

I have a Map in my class.How can i map it to a db table using a orm(hibernate for example)

Map contains key value pairs

key1 val1
key2 val2
key3 val3
key4 val4
开发者_运维技巧


That depends on what key and value actually represent. Using Hibernate look into either org.hibernate.annotations.CollectionOfElements (map primitives) or org.hibernate.annotations.MapKey (map entities).


For example:

    <map name="properties" table="MYENTITY_PROPERTY" lazy="true" cascade="all">
        <key column="MYENTITY_ID"/>
        <index column="PROPERTY_NAME" type="string"/>
        <element column="PROPERTY_VALUE" type="string"/>
    </map>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜