Dos and Don'ts
Serviceper use-case, should mostly delegate to
Commandsimplement use-cases or parts of it, and are thus reusable.
ActivitySearchwhen implementing use-case specific search - this allows privilege checking.
- One Transaction at a time - no TX inside of another TX.
- Commands are added to TXs and performed on close:
tx.flush() if you need to perform first some work and then as late as possible call
- Only access
ElementMaps if really no other way, mostly use
tx.findBy()and queries - if a specific get is missing, then add the method to
StrolchTransactionand send a pull request!
tx.stream*()methods to iterate over all elements, if you don't want to use a search.
- Don't write logic in REST API beans. Delegate to other services, making your code reusable!
- Transform to JSON using the
- References between objects is done by adding a
ParameterBagwith the id
relationsto the object and then
StringParameterswith the value being the ID, the UOM set to the type of element being referenced and the Interpretation set to the class type being referenced.