You can mix and match generated code with manually implemented code.
All generated methods and variables are marked with the Javadoc tag @generated.
If you want to modify generated code, remove this tag
so that your changes will not be overwritten.
Note: If a method is designed in an object diagram,
it cannot be edited as Java code. The Java code will then be overwritten.
To edit it, you need to remove the @generated Javadoc tag
or delete the method and create it again.
You can override the default generated annotations by designing tags on classes, attributes and associations. The figure below shows the most important annotations on classes and attributes.

Associations will automatically get annotations
@OneToOne, @OneToMany,
@ManyToOne or @ManyToMany.
mappedBy will be generated for bidirectional assocations
and optional=false for multiplicity 1.
@Embedded is generated for composites.

Other annotations can be designed as follows:

To design a different id than the default Long id
with @GeneratedValue,
right click on a class symbol and select Show Id.
Then, you can edit the name and type of the id and design annotations.
The following annotations are not supported yet:
@IdClass, @EntityListeners, @OrderBy, @MapKey.
A full reference of JPA annotations can be found at Oracle.
The generation of the .hbm.xml files can be completely controlled by a Groovy template. To enable this, copy hbm.template to the Project directory and modify it as desired.
One possible use of hbm.template is to enforce database naming conventions like All table names should start with TB_.
Hint: It is easiest to edit the template little by little, then save a class diagram and see the results in the generated mapping file.

Read more about Groovy templates here.
Elements and attributes in the Hibernate mapping file can be designed with tags, for example:
length=1000 (sets the column length to 1000)unique=true (a unique constraint)type=text (let a String column have type text instead of varchar)lazy=true (use lazy loading)
This can be designed with tags.
To create a tag, right-click on a class, attribute or assocation
and select New Tag.
This will create a tag with the name @hibernate (if the platform is Hibernate).
Right-click on the tag and select the New Parameter command,
and edit the parameter to unique=true to design a unique constraint.
By default, associations are generated as sets.
To generate list, map, bag, idmap, many-to-one, one-to-one or component
mapping for an association,
design a tag like @set, @list etc.
To create a tag on a class, attribute or association end,
right-click on it and select New Tag.
For associations, you can use a @hibernate tag
if you want to use the default mapping for the association
instead of specifying it with @set, @list etc.

To design a different id than the default Long id with native generator,
right click on a class symbol and select Show Id.
Then, create a tag on the id attribute and design the desired metadata.

Note that it is not possible to delete the <<id>> attribute, only to change its name and/or type. If you really want to modify this behavior, you can do so by modifying the PersistentClassBuilder.groovy script, so it doesn't create an <<id>> as soon as the old one is deleted. (See Design Scripts.)
To design aggregates, use the
button,
or change an association into an aggregate with the Aggregate.
Aggregates to many (*) objects will be generated as cascade="all" in the Hibernate mapping file.
This means that Hibernate will cascade save and update operations from the parent to the child objects.
If the child has a 1 relation to the parent, cascade="all,delete-orphan" will be generated.
This means that if the parent object is deleted, the child will be deleted automatically.
An XML schema can be generated for all the classes in a package. Right-click on a package in the Project Explorer and select Generate XML Schema. This will generate an xsd file with the classes in the package when the project is saved.
The xsd file is generated by a Groovy template xsd.template that is created in the project. This template can be modified to alter rules of the file generation. For example, a project may use a dedicated tag on classes to determine wheter they are part of the XML schema.