Collection type Mappings

Source: Internet
Author: User

  1. Set unordered elements are not repeatable
    1.   
      1  Public class Studentset {2     Private int ID; 3     Private String name; 4     Private New Hashset<string> ();

      1 <?XML version= "1.0"?>2 <!DOCTYPE hibernate-mapping Public3 "-//hibernate/hibernate Mapping DTD 3.0//en"4 "Http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">5 6 <hibernate-mapping Package= "Com.base.model">7 8     <classname= "Studentset"Table= "T_studentset">    <!--the class name and the corresponding data table name -9         <IDname= "id"column= "Stuid">            <!--field name, setting primary key -Ten             <Generatorclass= "Native"/>             One         </ID> A         < Propertyname= "Name"column= "Stuname"/>            <!--normal field - -          -         <Setname= "Images"Table= "T_image">        <!--A new table was created - the             <Keycolumn= "StudentID"></Key>         -             <elementcolumn= "ImageName"type= "string"></element> -         </Set> -     </class> +  - </hibernate-mapping>

  2. List ordered elements can be repeated
    1. One more list-index column relative to set, you can find
    2. 1         <Listname= "Images"Table= "T_imagelist">        <!--A new table was created -2             <Keycolumn= "StudentID"></Key>//FOREIGN key3             <List-indexcolumn= "ImageIndex"></List-index>//Primary key4             <elementcolumn= "ImageName"type= "string"></element>5         </List>

  3. Bag unordered elements can be duplicated
    1. Ibag tags using the list property
    2. 1 <Idbagname= "Images"Table= "T_images">2     <Collection-idtype= "int"column= "Imagesid">//Primary key3         <Generatorclass= "Increment"/>//Build Policy4     </Collection-id>5     <Keycolumn= "StudentID"></Key>//FOREIGN key6     <elementcolumn= "ImageName"type= "string"></element>7 </Idbag>

  4. Map Key value pairs
    1. Federated primary Key
    2. 1 <Mapname= "Students"Table= "Student">  2        <Keycolumn= "team_id"></Key>  3        <Map-keycolumn= "Name"type= "Java.lang.String"></Map-key>4        <elementcolumn= "description"type= "string"></element>5 </Map>  6   

Collection type Mappings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.