Atitit. ORM Mapping CFG Mapping Configuration (3)-------hbnt One2maney cfg

Source: Internet
Author: User

Atitit. ORM Mapping CFG mapping configuration (3)-------hbnt One2maney cfg

1. Create list 1

2. Configuring XML 1

3. configuration of Set and list in Hibernate 1

4. Bag(combined with List and Set), 2

1. EstablishList

/**

* Collection properties can only be declared with an interface. For example, in the following code, the type of schools can only be a list and cannot be ArrayList, but the collection property must be initialized with the implementation class.

*/

Public list list = new ArrayList ();

2. ConfigurationXML

<!--o7o ati ---

<!--Many starts with a foreign key that represents the table- -

<!--key is a foreign key - -<!--list is an ordered collection, so you must add a column to represent the order of the collection elements when persisting the class to the database

          . The list element requires List-index child elements to map the ordered collection's order column: jieg &NBSP;ORDER&NBSP; col &NBSP;MUST&NBSP;IN&NBSP;TABLE&NBSP; def

yaosi b tigon column, Zeu def C9>sh "idx"

List_order int Not null,

-   

< List name = "List" >

< Key column = "programme_id" />< List-index column = "Play_order" ></ List-index >

< One-to-many class = "Com.focustar.programme.entity.GvProgrammeDetail" />

</ List >

Author:: Old Wow's paw attilax Ayron, email:[email protected]

Reprint please indicate source: Http://blog.csdn.net/attilax

3. HibernateinSetand theListthe configuration

(2010-11-16 14:11:57)

Reproduced

It

Category: Learning summary

· Set Mappings:

<set name= "Addrs" table= "EMAIL" >

<key column= "c_id"/>

<element type= "string" column= "ADDRESS"/>

</set>

· List mappings:

<list name= "Addrs" table= "EMAIL" >

<key column= "c_id"/>

<index column= "LISTINDEX" > (a little bit of the set mapping is the list has a field that describes the subscripts)

<element type= "string" column= "ADDRESS"/>

</list>

com.microsoft.sqlserver.jdbc.SQLServerException: Column name ' idx ' is invalid.

4. Bag(combined withListwith theSet),

A collection that can be duplicated and has no order, which is provided by Hibernate. Hibernate uses the JDK's list simulation bag. Its configuration is basically the same as hibernate mapping list .

Related Article

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.