hibernate(hbm.xml.jet) - Hibernate configuration file

Introduce

Generate the hibernate configuration file.

Related knowledge:

Task

Model

Tag


Task And Model

The model group of the current task is shop, 
which contain a Java entity model book, 
and the relation value of book is one;

More about the model structure of this demo, please click: Demo model structure 

There are 2 ways to select the model:

We have created the following properties for this model:
Class: A head uppercase property, 
       which can be used as the class name or a part that need head uppercase.
       It's value is "Book".
class: A lowercase property, 
       which can be used as a part that need lowercase.
       It's value is "book".
menu: The name of the menu bar, and it's value is "Book".

Initialization

Generate mapping

Format:
<class name="Class" table="table">
The primary key's mapping format is:
 <id name="field.name" type="field.fullType">
   <column name="field.name" />
   <generator class="identity" /> 
 </id>
The others mapping format is:
 <property name="field.name" type="field.fullType">
   <column name="field.id" /> 
 </property>

What's the difference between id and name?

Id is consistent with the field name of the database table, and name is the new name after the mapping.
For example, according to the database naming convention, there is a field regist_time, which is mapped to the model and then converted to registTime.

Result

Tip: isPk is used to judgment a field is a primary key. 
If true, the field is a primary key; false is a non primary key.
Here, the mouse selects the if tag in the test to see the result of the judgment.