Hibernate with Xdoclets Code Completion

After creating hibernate bean from template you can use code completion to add these templates:

Hibernate property

Hibernate property generates implementation for hibernate property. The hibernate customizer wizard is the same like customizer for hibernate property in Hibernate bean wizard.

1-1 relation

1-1 relation template helps to create relation between two beans. The second bean of relation is specified in Target Class Name field. It should be chosen in package view of project. The package view should be shown by clicking on Browse button.

Only hibernate beans are visible in the package view. It is posible to create bidirectional relation where the code is generated to the both classes. To make bidirectional relation select the Bidirectional Relation checkbox. You can also specify the variable name in generated classes for the the participated beans in relation. The generated code is bellow.

Generated code in the User class (source):

Expanded code

Generated code in the Address clas (destination):

Expanded code

1-N/N-1 relation

This template generates code for ONE to MANY and MANY to ONE relation between two beans. The customizer for the template is bellow.

Target Class Name field contains class name of the second hibernate bean in the relation. The class name should be selected in package view. The package view should be shown by clicking on Browse button. Foreign Key field is name of foreign key which will be used in database for representantion of 1 to MANY relation. The code should be generated to

Example of generated code in the User class (source):

Expanded code

Generated code in Acount class

Expanded code

M-N/N-M relation

This template generates code for MANY to MANY relation between two beans. The customizer for the template is bellow.

The customizer is similiar like the 1-N/N-1 customizer. There is one more field for foreign key. Hibernate generate special table in database to establish this relation.

Example of generated code in User class

Expanded code

Generated code in Car class

Expanded code