Issue Type: Bug Bug
Affects Versions: 4.1.3
Assignee: Unassigned
Components: core
Created: 15/Jun/12 1:42 PM
Description:

The problem seems to be in EntityType because it's replacing the children object with all the values to be merged with a fresh instance of the class, which makes no sense and causes the merge operation to fail in to merge children values (they get all lost)

at line 283:

if ( session.getContextEntityIdentifier( original ) == null &&
ForeignKeys.isTransient( associatedEntityName, original, Boolean.FALSE, session ) ) { final Object copy = session.getFactory().getEntityPersister( associatedEntityName ) .instantiate( null, session ); //TODO: should this be Session.instantiate(Persister, ...)? copyCache.put( original, copy ); return copy; }

copyCache.put( original, copy ); <-- the original key gets a fresh entity with no attributes, so all its values are lost and consequently don't get merged

test case:

@Test
public void shouldCascadeToChildren() throws Exception { Parent parent = aParent(); parent.addChild(aChild()); repository.add(parent); List<Child> children = repository.getChild(parent); Assert.assertThat(children, hasItem(parent.getChildren().get(0))); }

Project: Hibernate ORM
Priority: Major Major
Reporter: pedro santos
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira