Consider throwing UnsupportedOperationException when a bytecode-enhanced entity's clone method is called

Description

When a bytecode-enhanced entity is cloned, both the original and clone have references to the same enhanced fields. This can result in unexpected behavior.

For example, Hibernate will use the same EntityEntry for both the original and clone because the enhanced getter $$_hibernate_getEntityEntry() for both entities will return the same EntityEntry object.

If the application attempts to delete the original entity, and set a different ID in the clone to persist, Hibernate will attempt to "resurrect" the deleted entity, but will throw an exception because there is no "delete" action scheduled for the clone.

Environment

None

Assignee

Unassigned

Reporter

Gail Badner

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure