Skip to content

Propagate read-only status to Hibernate Session through setDefaultReadOnly [SPR-16956] #21494

Closed
@spring-projects-issues

Description

@spring-projects-issues

MIhalcea Vlad opened SPR-16956 and commented

By default,  @Transactional(readOnly = true) sets the FlushMode to MANUAL. However, Hibernate can save up lots of memory by discarding the associated hydrated state if we also set the session.setDefaultReadOnly(true).

Not only that we save memory, but we also save CPU cycles because, if the user tries to do a manual flush, we won't propagate it to any entity since they are virtually read-only.


Affects: 5.0.7

Issue Links:

Referenced from: pull request #1861, and commits 010ba33, d22d408

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions