<?xml version= "1.0"? ><! DOCTYPE hibernate- mappingPublic "-//hibernate/hibernate mapping DTD 3.0//en" "/http HIBERNATE.SOURCEFORGE.NET/HIBERNATE-MAPPING-3.0.DTD ">mapping package =" Com.myschool.entity "> <class name=" admin "table=" admin "lazy=" true "> <id name=" LoginId "column=" LoginId "> class=" Assigned "></generator><!--assigned external program designation - </id> <property name= "loginpwd" type= "string" column= "Loginpwd"/> </ Class>
The meanings of each element are as follows:
Class: Defines the mapping information for a persisted class. Common properties are as follows:
Name indicates the fully qualified name of the persisted class
Table represents the database table name for the persisted class
Schema represents a user in a DB instance
ID: The mapping that represents the oid of the persisted class and the primary key of the table. Common properties are as follows:
Name: Represents the names of persisted class properties, and the accessors of the properties match
Type: Represents the types of persisted class properties
Column: Name of the database table field that corresponds to the persisted class property
A child element of the Generator:id element that specifies the generation strategy for the primary key. Common attributes and sub-elements are as follows:
Class: Used to specify a specific primary key generation strategy
Param used to pass parameters
The common primary key generation strategy is as follows:
Increment: A primary key of type long, short, or int that generates the value of the primary key in an auto-grow manner. The primary key is incremented in numerical order, with increments of 1
Identity: For databases that support identity columns such as SQL Server, DB2, MySQL, and so on, you can use this primary key generation policy to generate an autogrow primary key, but set the book sword as an identity column in the database
Sequence: For databases that support sequences such as Oracle, DB2, you can use this primary key generation strategy to generate an autogrow primary key, param the name of a sequence in the incoming database through a child element
Native: Based on the underlying database, Hibernate determines which primary key generation strategy to use, generating the value of the primary key from the database used
Assigned: The primary key is generated by the application complex, without hibernate involvement
Property: Defines the correspondence between the properties in the persisted class and the fields of the database table. Common properties are as follows:
Name: Names that represent persisted class properties, and property accessors match
Type: Represents the types of persisted class properties
Column: Name of the database table field that corresponds to the persisted class property