Hibernate's core object-relational mapping

Source: Internet
Author: User

The core of Hibernate is Object Relational mapping:

(1) The first master mapping file writing:

(2) Second master How to map an object and the settings of the primary key and normal field in class.

<class name= "user" table= "user" >

Note: The value of the column attribute of the property cannot be the keyword of the SQL statement, such as the DESC keyword to describe the time, if not to use, you can use the "(shift+~) anti-quotation marks, or to change the column name;

1<?xml version= "1.0"?>2<! DOCTYPE hibernate-Mapping Public3"-//hibernate/hibernate Mapping DTD 3.0//en"4"Http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >5     6<!--7 The first part: Mapping Files: Mapping an entity class object that describes an object's eventual implementation that can save object data directly into the database8      Package(optional): The object to be mapped is the package in which the entity class resides, and if you do not specify packages, all of the following classes specify the full path9-Ten Package= "Com.bie.po" > One<!--operating conditions: (1): Objects and Tables/(2): Properties correspond to Fields/(3): Type, type default, type not written A- -       -<!--Part II: the(1):class: Mapping An object (typically, an object writes a mapping file, which is a class node); - Name: Specifies the type of object to be mapped, the entity class name; - Table : Specify the tables to be mapped, table names; -(2): Primary key mapping: ID +(3): Normal field Mapping: property - Name : Specifies the property name of the object; + column: Specifies the field name of the table that corresponds to the object property, and the default is consistent with the object property if not written; ALength: Used to specify character type lengths, such as String type varchar (20), default length 255; at Type : Used to specify the types of fields for a table, and if not specified, matches the type of the property and contains two types; - Java type: Must write full name, such as Java.lang.string,java.util.date - Hibernate type: For example, string,date, all lowercase, cannot write string (cannot capitalize the first letter) -NOTE: The DESC keyword can be used "(shift+~) Anti-quote or change column name -- -<className= "User" table= "user" > in<!--primary key, map--- -<id name= "id" column= "id" > to<generatorclass= "Native" ></generator> +</id> -          the<!--non-primary key, map--- *<property name= "name" column= "name" ></property> $<property name= "password" column= "password" ></property>Panax Notoginseng<property name= "Email" column= "email" ></property> -<property name= "Phone" column= "Phone" ></property> the          +          A</class> the  +

Gree, master the core technology, so that consumers love Chinese-made!!!

Hibernate, master the Core knowledge of mapping, let the Boss give you a promotion salary!!! ~.. ~

Hibernate's core object-relational mapping

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.