set:An unordered collection that can't duplicate elements is called a set
<set name="images" table="ITEM_IMAGE">
<key column="ITEM_ID" /> <element type="string" column="FILENAME" not-null="true" /> </set> ITEM_ID,FILENAME:PK. (because there don't permit duplicate)
ITEM_ID:FK refer owner (PK) bag:An unordered collection that permits duplicate elements is called a bag <bag name="items" table="user_item"> <key column="id" /> <element column="name" type="java.lang.String" /> </bag> id:FK refer owner(PK) it havs a bad performance when update,because it can't location. ibbag:An unordered collection that permits duplicate elements is called a bag,more effect than bag,because there have another filed used to location,e.g:ITEM_IMAGE_ID
<idbag name="image_bag" table="ITEM_IMAGE_bag">
<collection-id type="long" column="ITEM_IMAGE_ID"> <generator class="native" /> </collection-id> <key column="ITEM_ID" /> <element type="string" column="FILENAME" not-null="true" /> </idbag> ITEM_IMAGE_ID:PK ITEM_ID:FK refer (owner) PK list: An ordered collection that permits duplicate elements is called a list.
<list name="images_list" table="ITEM_IMAGE_list"> <key column="ITEM_ID" /> <list-index column="POSITION" /> <element type="string" column="FILENAME" not-null="true" /> </list> list:
item_id,position:PK item_id:FK refter (owner) Pk <map name="images_map" table="ITEM_IMAGE_map">
<key column="ITEM_ID" /> <map-key column="IMAGENAME" type="string" /> <element type="string" column="FILENAME" not-null="true" /> </map> Map:
ITEM_ID,IMAGENAME:PK ITEM_ID:FK refer owner (PK) |
|
来自: moonboat > 《hibernate》