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