Hibernate configuration file Template

Source: Internet
Author: User

Hibernate.cfg.xml configuration file Template:

<?xml version= ' 1.0 ' encoding= ' UTF-8 '?> <! DOCTYPE hibernate-configuration Public "-//hibernate/hibernate configuration DTD 3.0//en" "Http://ww          W.hibernate.org/dtd/hibernate-configuration-3.0.dtd "> 

Hibernate.cfg.xml configuration of the <mapping> mapping file, resource attribute values need to fill in the specific path, such as: placed in the Com.uzipi.entity package Student.hbm.xml, paired with:

<mapping resource= "Com/uzipi/entity/student.hbm.xml"/>

If you are configuring a map by annotation, the attributes of the <mapping> element configured in the Hibernate.cfg.xml file are class, and the fully qualified class name of the class is filled in:
<mapping class= "Com.uzipi.entity.TClass"/>



XXX.hbm.xml Mapping File Template:

<?xml version= "1.0" encoding= "UTF-8"?> <! DOCTYPE hibernate-mapping Public "-//hibernate/hibernate mapping DTD 3.0//en" "Http://hibernate.sour Ceforge.net/hibernate-mapping-3.0.dtd "> 

The <property> attribute element is configured in two ways: paired, single.

Paired configuration requires a <column name= "xxx"/> element to be configured within the <property> element.

If the column and type attributes are not configured in the mapping file, Hibernate will default to match the fields in the database table with the property names and property types in the persisted class.

The child element of the <id> element <generator> is used to generate a unique identity for an instance of a persisted class, a primary key field in the mapping database, and a common configuration value for the class attribute:

Increment: Used to generate a unique identity for a long, short, int type. Do not use this property under cluster

Identity: The underlying implementation of the database supporting the self-increment field type, providing the ability to generate a primary key (e.g. MySQL)

Sequence: Provides the ability to generate a primary key (e.g. Oracle) by a database underlying implementation that supports sequences

Native: Automatic recognition of database by Hibernate implementation, automatic selection of identity, sequence (general configuration of this property)

Assigned: The Hibernate program is responsible for generating the primary key, at which point the unique identity of the persisted class cannot be declared as private type

Select: Generate a primary key from a database trigger

Foreign: Use the identifier of another associated object, usually with <one-to-one>

Hibernate configuration file Template

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.