How to model Object Mappings
JEAF Generator offers the possibility to unburden developers from error-prawn and boring job of mapping objects from one into another. To do so, a so called object mapping can be defined in the UML model by defining dependencies between attributes using stereotype «ObjectMapping»
. Object mappings distinguish between creating, updating and reading of objects. As you will see below behavior of an object mapping can be defined for each of the cases.
As you can see above, to define an object mapping a dependency between attributes of two classes is required. This dependency is to be tagged with stereotype «ObjectMapping»
. Using tagged value onCreate
, onUpdate
and onRead
you can define when the dependencies should be taken into account from the generated code.
As you can it’s also possible to use operations on the target side instead of properties. However this is only possible for objects mapping with onRead
only strategy.
Source | Target | |
---|---|---|
| Attribute | Operation |
Attribute |
|
|
Operation |
|
|
When defining object mappings it’s also important to have a look on the table below. As you can see only some combinations between source and target object types are supported.
Source | Target | |||
---|---|---|---|---|
| Service Object | POJO | Domain Object | Persistent Object |
Service Object | ||||
POJO | ||||
Domain Object | ||||
Persistent Object |
|
|
|
For further information please also refer to: