Creating an identifier

Simple identifiers

An identifier is an attribute of a persistent class enabling this class to be identified in a unique way. In most cases, identifiers are mapped as SQL model primary keys.

An identifier belonging to a persistent class

To transform a persistent model attribute into an identifier, just check the “Identifier” tickbox.

You can define the following properties for an identifier in the SQL tab:

Generators

A generator is used to generate unique identifiers for instances of persistent classes.

The “Generator” property on an identifier assigns a type of generator to the indentifier in question. Some generators require parameters. The “Parameters” property on an identifier is used to enter these parameters using the following syntax: paramname1, paramvalue1 ; paramname2, paramvalue2 ;…

Composite identifiers

If a persistent class has more than one identifier, then we refer to composite identifiers. These compositie identifiers are mapped on composite primary keys in the SQL model.

The presence of a composite identifier results in a number of constraints: your persistent classes must overload the equals() and hashCode() methods. They must also implement the Serializable interface.

If these methods are missing, the Hibernate Designer module will automatically create the skeletons of these operations during Java generation. It will also add an implementation link to the Serializable interface where necessary.