Hibernet Mapping
Collection mappings:
The property fields of the class are collections.
Set
<set name= "property field" table= "property Field table Name" >
<key foreign key column= "" >
<element column= "Property stores the location name of the content" Type= "" >
Mapping of Set collection properties
Name specifies the properties of the set collection to be mapped
Table to which to map table collection properties
KEY specifies the foreign key field of the collection table (t_address)
element specifies other fields of the collection table
Type element, be sure to specify
List
<list name= "property field" table= "property Field table Name" >
<key foreign key column= "" >
<list-index column= "Index" > list is ordered, this is used to sort the
<element column= "Property stores the location name of the content" Type= "" >
--
List Collection Mappings
LIST-INDEX Specifies the name of the row sequence (because the list collection is guaranteed to be ordered)
Map
<map name= "property field" table= "property Field table Name" >
<key foreign key column= "" >
<map-key column= "First content: Property stores the location name of the content" Type= "" >
<element column= "Second content: property stores the location name of the content" Type= "" >
Map for map Collection
KEY specifies the foreign key field
Map-key the key of the specified map
element specifies the value of map
One-to-many, many-to-a
<many-to-one name= "property field" calss= "The name of another class" column= "Foreign key Field" >
<one-to-mony calss= "Name of another class" >
In a one-to-many-to-many relationship, the best way to preserve the data is to maintain the relationship through many parties, which can reduce the generation of the UPDATE statement and improve hibernate execution efficiency!
Attention:
Configure which party, which has to maintain the rights of the association relationship!
Inverse property
The inverse property is useful when maintaining an association relationship.
Indicates whether control is transferred. (works on one side)
Inverse, control reversal.
Inverse = false does not reverse; when there is control over the front
True control reversal; current party has no control
Cascade indicates that a cascade operation "can be set to one or more of the other side"
None cascade operation, default value
Save-update Cascade Save or update
Delete Cascade deletion
Save-update,delete Cascade Save, UPDATE, delete
All ibid. Cascade Save, UPDATE, delete
Many-to-many
<many-to-many column=" the ID of another class " class=" the name of another class " ></ Many-to-many>
Many-to-many
column specifies the item field corresponding to the Foreign key field
Type of class collection element
Hibernate mapping 1