UML Modeling Guide

Stereotype «Role»

Stereotype «Role»

Stereotype «Role» can be used to map associations between two persistent objects to a relational database. The stereotype can be applied on the ends of an association and it is required that the classes on both association ends have assigned stereotype «Persistent Object».


Stereotype «Role»  
Applicable Elements Property  
Tagged Values    
Name Type Description
linkTable String In object relational mapping a so called link table is required when m:n associations should be mapped to a database. This attribute can be used to define the name of the link table.
cascade CascadeType Attribute cascade can be used to define what should happen with the object on the applied association end when the other objects is saved, updated or deleted. It is possible to define more than one cascade type.

The following cascade types can be used: NONE, SAVE-UPDATE, PERSIST, MERGE, DELETE, REMOVE, LOCK, REPLICATE, EVICT, REFRESH, ALL and DELETE_ORPHAN

As JEAF Framework uses Java Persistence API (JPA) for persistence the concrete details about the cascade types can be taken from their documentation.

Default value is NONE.
notlazy Boolean By default persistence frameworks only load referenced objects from the database when they are accessed (lazy loading). In general this behavior is fine, but there are cases where this behavior is unsuitable.

By setting attribute notLazy = true it’s possible to tell persistence frameworks that lazy load should not be used for an association end. Default value is false.
foreignKeyName String Attribute foreignKeyName can be used to define the name of the foreign key row on the database. If the attribute is not set then the name is derived from the role name of the association end.

Note: The foreign key name has to be defined on the association end with multiplicity 0..1 or 1. The attribute can not be used in case of m:n relations.
foreignKeyOwner Boolean In case of 1:1 relations between classes in object relational mapping it is not clear on which side a foreign key should be stored. In this case attribute foreignKeyOwner has to be set on one end of an association.

As the attribute is only relevant for 1:1 associations it default value is false.
fetchType FetchType Attribute fetchType defines the way how persistence frameworks deal with loading of references of this associations. Depending on the concrete scenarios of your application you should choose the best matching fetch type.

The following options are available:
- SELECT means that the association will be loaded lazy (on access only). Persistence frameworks therefore will send an additional SQL statements to the database to load all referenced objects. If you are using this option then we strongly recommend to also make use of attribute batchSize. Otherwise you will run into the so called n+1 problem, which will end up in way too many SQL statements and poor performance due to that.

- JOIN means that associated objects will already be loaded when the object holding the association is loaded. This is also called eager loading. Persistence framework will be able to do so with only 1 SQL statement but you will load way more data into memory which might not be needed.

- NONE means that the fetch type will not be set in the persistence mapping. In this case the default behavior of the persistence framework will be used.
We strongly recommend to only use this setting in early development stages :wink:
batchSize Integer Attribute batchSize defines the amount of objects that are read at once when using batch fetching. Batch fetching can only be used on association ends with multiplicity 0..* or 1..*. Batch fetching is enabled by defining a batch size.

Further details about batch fetching can be taken from JPA documentation.


For further information please refer to:


Generated by JEAF Generator