Bernardo-MG / development-docs

Documentation and guidelines to help in the development of my own projects.
https://bernardo.gitbook.io/development-docs/
MIT License
0 stars 0 forks source link

Comment about not returning persistence entities #114

Open Bernardo-MG opened 6 years ago

Bernardo-MG commented 6 years ago

Persistence entities should not be used outside a transaction. This means for example they should not be used to generate JSON messages.

The problem here is that lazy fields may not be initialized before generating the JSON.

Bernardo-MG commented 6 years ago

There is also the reverse problem. When working with entities inside a transaction a change to the entity may be persisted, even when not stated explicitly.