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 .