When lazy fetching child entities outside the session DB commit is fired in a readonly transaction.

Description

When lazy fetching a child entity outside the session that loaded the parent entity, hibernate will open a temporary session if "hibernate.enable_lazy_load_no_trans" is set to true. As part of this it opens a temporary session & then sets the transaction to read only. However, after lazyInitializationWork.doWork() in the finally block it fires a commit() if we are in nonJTA environment. This to me looks like it can be avoided.

Environment

INFO: HHH000412: Hibernate Core {5.2.7.Final}
INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}

Status

Assignee

Vlad Mihalcea

Reporter

Sudheer Bhat

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure