Use xDoclet For Hibernate

xDoclet在Hibernate中的使用

    Hibernate类:

     @hibernate.class 
table="teacher"


    Hibernate子类:

     @hibernate.joined-subclass 
@hibernate.joined-subclass-key 
column="tea_id"


    主键:

     @hibernate.id 
column="tea_id" 
generator-class="native"


    普通属性:

     @hibernate.property 
column="tea_name" 
1:n(1对多)


    1的一头:

     @hibernate.set 
lazy="true" 
cascade="all" 
inverse="true" 

@hibernate.collection-keycolumn="tea_id" 

@hibernate.collection-one-to-manyclass="tms.Teacher.ZBJiangCheng"


    多的一头:

     @hibernate.many-to-one 
column="tea_id" 
class="tms.Teacher.ZBTeacher" 
not-null="true" 
1:1(1对1)


    1的一头:

     @hibernate.one-to-one name="gongzi" 
class="tms.Teacher.ZBGongzi" 
cascade="all"


    1的另一头:

     @hibernate.one-to-one 
name="teacher" 
class="tms.Teacher.ZBTeacher" 
constrained="true"


    并且其主键策略应是:

     @hibernate.id 
column="tea_id"
generator-class="foreign"
unsaved-value="0"

@hibernate.generator-param
name="property"
value="teacher"


    另一种一头维护的1:1关系

    (例如:一本书对应一个图书类型,一种图书类型对应多本书,图书类型一端不需维护对应什么书,而书的一端应维护对应哪种图书类型)

     @hibernate.many-to-one 
name="booktype" 
column="booktype_id" 
cascade="all" 
not-null="true"


你可能感兴趣的:(Hibernate)