Use XDoclet for hibernate
Use of XDoclet in hibernate
Hibernate class:
@ Hibernate. Class table = "teacher" |
Hibernate subclass:
@ Hibernate. Joined-subclass @ hibernate. Joined-subclass-key column = "tea_id" |
Primary key:
@ Hibernate. ID column = "tea_id" generator-class = "native" |
Common attributes:
@ Hibernate. Property column = "tea_name" 1: n (1-to-many) |
One end of 1:
@ Hibernate. set lazy = "true" cascade = "all" inverse = "true" @ hibernate. collection-keycolumn = "tea_id" @ hibernate. collection-one-to-manyclass = "TMS. teacher. zbjiangcheng" |
Multiple ends:
@ Hibernate. Category-to-one column = "tea_id" class = "TMS. Teacher. zbteacher" not-null = "true" (1 to 1) |
One end of 1:
@ Hibernate. One-to-one name = "gongzi" class = "TMS. Teacher. zbgongzi" cascade = "all" |
The other end of 1:
@ Hibernate. One-to-one name = "teacher" class = "TMS. Teacher. zbteacher" constrained = "true" |
And its primary key policy should be:
@ Hibernate. ID column = "tea_id" generator-class = "foreign" unsaved-value = "0" @ hibernate. Generator-paramname = "property" value = "teacher" |
Another type of 1-1 relationship maintained by one end
(For example, a book corresponds to a book type, and a book type corresponds to multiple books. one end of the book type does not need to maintain the corresponding books, and the other end of the book should maintain the corresponding types of books)
@ hibernate. feature-to-one name = "booktype" column = "booktype_id" cascade = "all" not-null = "true" |