Hibernate: Persistent class map file

Source: Internet
Author: User
Tags generator

<?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

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.