Merge can fail when there is a transient entity reachable by multiple paths and at least one path does not cascade on merge

Description

Cascade rules are prone to different behavior based on the order in which properties appear in mapping XML. It is possible that an unexpected TransientObjectException may arise from certain operations when an object graph with circular references is merged (and possibly persisted/updated, etc).

For example, if a transient instance is reachable through more than once path from a root entity, it is not clear whether operations will be cascaded to it. The order in which the properties are mapped plays a part in determining cascade paths, but the rules are not documented.

Possible resolutions include:

1. Documenting the rules so that a programmer can make educated decisions about mapping.
2. Enhancing the algorithm such that order no longer matters and the rules are deterministic.
3. ???

Environment

None

Activity

Show:
Paul Benedict
June 10, 2008, 3:42 AM

Was the documentation ever updated so that more of Hibernate's design decisions are known on this issue?

Gail Badner
June 12, 2008, 9:16 PM

The fix involved a change to how merge is done so that the order of property cascades no longer affects merged results.

The other option was to document how the cascade order was determined and how the order affected merging a detached entity. Since this is no longer relevant, the documentation was not updated.

Pavol Zibrita
July 4, 2008, 11:40 AM

This issue was a partial fix for 3046, however 3046 still fails to store the object graph, now because of bad order of updates and inserts of parents and children.

Pavol Zibrita
April 27, 2009, 8:36 AM

Personally I think the patch in 3046 would fix this issue. With your fix, you also introduced another issue. Hm.

Steve Ebersole
March 21, 2011, 7:04 PM

Bulk closing stale resolved issues

Fixed

Assignee

Gail Badner

Reporter

Chris Bredesen

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