Duplicate flushes on native queries with Auto Flush

Description

Duplicate flushes occur when native queries are executed and the flush mode is set to auto.
For entities with complex types, equality comparisons can become expensive (large clobs / datastructures).
This could be avoided by checking if a flush has already occurred between the NativeQueryImpl.beforeQuery and SessionImpl.autoFlushIfRequired.

The attached spring project highlights the issue.
DupeFlushApplicationTest.testAutoFlush counts 2 flushes for one invocation to query.list()

Environment

None

Status

Assignee

Unassigned

Reporter

Kevin Brooks

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

3.6.10

Components

Affects versions

Priority

Major
Configure