We're updating the issue view to help you get more done. 

map-key-many-to-many and cascade="all-delete-orphan" do not work together

Description

It seems that if you have maps keyed by entities, they do not respect the cascade options. The attached test case shows this working for Map<String, Entity> but failing for Map<Entity, String> and Map<Entity, Entity> with 'object references an unsaved transient instance'.

The problem seems to be caused by the code treating maps as single type collections. As an example, calling getCollectionPersistor from Cascade for the Map<Entity, String> returns a BasicCollectionPersistor for String. The element type for the persistor is then claimed to be String and any cascading which should be performed on the key is ignored.

To pre-empt a solution I suspect will be proposed, I can't use nested components as the map keys as the objects these entities will represent in our system tend to be complex, self-referential hierarchies of arbitrary depth.

Environment

Hibernate 3.6.6 Final
Oracle 11.2.0.2.0

Status

Assignee

Unassigned

Reporter

d

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

3.6.6

Priority

Blocker