Hibernate Getting Started-----hiberna Core Documentation

Source: Internet
Author: User

Hiberna core File Detailed mapping file: *.hbm.xml

<?xml version= "1.0" encoding= "UTF-8"?> the DTD information for the mapping file. Open Hibernate.jar,    You can find the Hibernate-mapping-3.0.dtd file in the Org.hibernate package and copy the DTD constraint. <! DOCTYPE hibernate-mapping Public '-//hibernate/hibernate mapping DTD 3.0//en ' http://www.hibernate.  Org/dtd/hibernate-mapping-3.0.dtd ' > 

Hibernate-mapping element Properties
Defines the basic information for the mapping file.

&lt;hibernate-mapping package="包名" schema="数据库schema名 " catalog="数据库catalog名" default-access="property" default-lazy="true" default-cascade="none"&gt;
Package: Specify a packet prefix for the class in the mapping file so that name in class can write directly to the class, not the full class name
Schema: Specify database schema name
Catalog: Database Catalog Name
Default-access:hibernate the policy when accessing the property.

Property uses the Getter,setter method to access member variables.

Field accesses member variables in a reflection manner.

Default-cascade: Whether to use the default cascade
Default-lazy: Specifies that the default delay-loading policy is used. Default True
Class element properties
To describe a persisted class.

' <class name= ' the class name "table=" of the persisted class or interface indicates that the catalog name of the "catalog=" database is "lazy=" true "rowid=" "mutable=" true ">"
Name: The class name of the persisted class or interface
Table: Database table name, default to class name
Catalog: Catalog name of the database
Lazy: Whether to use lazy loading
Mutable: Are instances of classes mutable?
ROWID: Specifies whether ROWID can be used?
Class element properties

&lt;id name="类中OID属性名" column="列名" access="" type=""&gt;

Name: OID Property name in class
Column name, default property name
Access: Property access policy that overrides Defalut-access property in Hibernate-mapping
Type: The data type of the attribute, generally not written, the framework is automatically filled. The wrapper class is generally used in classes.
Generator child elements under the primary key generation policy--id property
Assigned:
1. A strategy is an ID generation strategy that the programmer manually controls the input data Model OID.
2. The default build policy.
Increment:
1. The database field is XXX data type.
2. A policy is an ID generation strategy that generates an OID from Hibernate internal control, with increments of + 1 per increment.
3. When multiple connections operate on a table at the same time, the same max value may be obtained, causing the same ID to occur. cannot be used in a clustered environment.
Identity:
1. Database underlying control generates an ID generation policy for OIDs.
2. The ID field in the database is an integer numeric type and is required to be set to a self-increment property
Sequence

An ID generation strategy for generating OID in database underlying control
Requires the ID field in the database to be an integer numeric type
Can only be applied to databases that provide sequence support, such as Oracle.
Native:
1. The corresponding ID generation policy is automatically selected in the (Identity,sequence,hilo) build policy based on the type of database used
Uuid:
1. Require that the ID field in the database be a string type

Property element Properties

&lt;property name="name" unique="false" not-null="true"/&gt;

Unique: Whether the column is unique
Not-null: Whether the column is allowed to be empty
Core configuration file: Hibernate.cfg.xml
Two types of formats:
1.properties property file format, key-value pairs hold information
2.xml file format. Most commonly used
Hibernate.cfg.xml files are generally placed under SRC. will be published under the Web-inf/classes path.

<?xml version= ' 1.0 ' encoding= ' utf-8 '?> The DTD information for the map file. Open Hibernate.jar, You can find the Hibernate-configuration-3.0.dtd file in the Org.hibernate package and copy the DTD constraint. <! DOCTYPE hibernate-configuration Public "-//hibernate/hibernate configuration DTD 3.0//en" "Http://www.hi Bernate.org/dtd/hibernate-configuration-3.0.dtd "> 

Getting Started with hibernate-----Hiberna core file

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.