hbm2Java是根据映射文件自动生成java源文件
hbm2ddl 是根据映射文件自动生成数据库schema
XDoclet 根据带有XDoclet的标记的java源文件生成映射文件
Middlegen 根据数据库Schema自动生成映射文件
1'<class name = "mypack.customer"
<meta attribute = "class-description"//指定下列为注释
Repesents a single customer
@author S
</meta
</class
2'<class name = "mypack.customer"
<meta attribute = "extends"mypack.BusinessObject</meta//指定类所继续的类
</class
3'<property name = "married" type ="boolean" column ="is_married"
<meta attribute = "field-description"is the customer married </meta//指定方法注释
</property
4'指定类、类的属性及类属性的get方法和set方法的修饰符可选:
static 、 public 、 abstract 、final 、 private
<id name = "id" type = "int"
<meta attribute = "scope-set"protected</meta
<generator class = "native"
</id
5'指定在类的toString()方法返回的字符串中是否包含特定的属性
<property name ="name" type ="string" not-null = "true"
<meta attribute ="use-in-tostring"true</meta
</property
////////////////<meta的元素属性表
class-description//指定描述类的javaDoc
field-description//指定描述类的属性的javaDoc
interface//假如为true,表示生成接口而非类,默认为false
implements//指定类所实现的接口
extends//指定类继续的父类名
generated-class//重新指定生成的类名
scope-class//指定类的修饰符默认为public
scope-set//指定set方法的修饰符默认为public
scope-get//指定get方法的修饰符默认为public
scope-field//指定类的属性修饰符默认为private
use-in-toString//假如为true,表示在tostring方法中包含此属性
gen-property//假如为false不会在java类中生成此属性,默认为true
finder-method//指定find方法名
///////////////<column制定数据库表
1'设定字段名、字段长度以及唯一性
<property name = "name" type ="string"
<meta attribute ="use-in-tostring"true</meta
<column name ="name" length ="15" not-null ="true" unique ="true"
</property//表示字段名为name长度为15不能为空具有唯一性
2'设定字段不为空,并且为这个字段设立检查约束。
<property name = "age" type ="int"
<meta attribute = "field-description"How old is the customer</meta
<meta attribute = "use-in-tostring"true</meta
<column name = "age" check ="age 10" not-null ="true"
</property
3'建立索引
<property name = "registeredtime" type ="timestamp"
<meta attribute ="field-description"When the customer was registered</meta
<meta attribute ="use-in-tostring"true</meta
<column name ="registerd_time" index = "idx_registerd_time" sql-type= "timestamp"
</property
4'建立对应的字段类型
<property name = "description" type ="string"
<meta attribute ="use-in-tostring"true</meta
<column name = "description" sql-type ="text"//根据相对应的数据库来定义字段的类型
</property