docs(document): add WHY comments to @Transactional(readOnly=true) methods
These annotations deviate from the project convention (read methods are normally unannotated). The comment explains that the session must stay open for callers to access lazy-loaded collections post-return, preventing future developers from removing the annotation as a cleanup. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -636,7 +636,8 @@ public class DocumentService {
|
||||
return saved;
|
||||
}
|
||||
|
||||
// 0. Zuletzt aktive Dokumente (sortiert nach updatedAt DESC)
|
||||
// @Transactional(readOnly=true) keeps the Hibernate session open so the
|
||||
// lazy-loaded sender and tags on returned documents remain accessible to callers.
|
||||
@Transactional(readOnly = true)
|
||||
public List<Document> getRecentActivity(int size) {
|
||||
return documentRepository.findAll(
|
||||
@@ -845,6 +846,8 @@ public class DocumentService {
|
||||
documentRepository.save(doc);
|
||||
}
|
||||
|
||||
// @Transactional(readOnly=true) keeps the Hibernate session open so the
|
||||
// lazy-loaded tags and receivers on the returned document remain accessible to callers.
|
||||
@Transactional(readOnly = true)
|
||||
public Document getDocumentById(UUID id) {
|
||||
Document doc = documentRepository.findById(id)
|
||||
|
||||
Reference in New Issue
Block a user