Persist of detached entity in derived ID

Description

When a @ManyToOne relation is present on a composite key, Hibernate tries to persist that object even if no persist operation is done on the parent entity. This cause PersistentObjectException when an entity is retrieved from cache and Hibernate tries to persist its detached @ManyToOne key.

For example:

A first query.getSingleResult() works, but all subsequent ones throw this:

Environment

WildFly 10.0

Status

Assignee

Gail Badner

Reporter

Giovanni Lovato

Fix versions

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Blocker
Configure