flush triggers load when using enableDirtyTracking

Description

When bytecode enhancement (enableDirtyTracking) is activated, a flush triggers a load on every proxy instance.

The problems seems to be that the proxy is "around" the ManagedEntity implementation (which is this case is the not-loaded entity). Therefore the proxy is accessed to check the entity state. This access causes the load.

Find attached a sample application. You can trigger the problem by running "mvn clean test". When enableDirtyTracking is deactivated, the problem does not occur and the "Child"-entity is not loaded (see also SQL statements).

Environment

Hibernate 5.2.1, any database

Assignee

Luis Barreiro

Reporter

Alexander Pinske

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure