PropertyAccessException when instance of a subclass gets to cache via lazy not cascading association

Description

In org.hibernate.type.EntityType possible situations when created instance of the superclass, while instance of the subclass needed. It happens when replace method called on the instance of a subclass, but association target is superclass and instance is not cached.
Pull request with test case illustrating one of such situations (when object gets to cache via lazy not cascading association) and containing bug fix following.

Environment

None

Status

Assignee

Brett Meyer

Reporter

Vasily Kochnev

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Critical
Configure