| So, AFAICS, this is a bug, or at least an undesired behavior. The issue comes from the fact that CascadeEntityJoinWalker overrides isJoinedFetchEnabled() and enables eager loading via join no matter how the collection is set. It also has:
@Override
protected boolean isTooManyCollections() {
return countCollectionPersisters( associations ) > 0;
}
so it only does that for the very first collection thus the strange behavior you have, loading lines but not taxes. I tried to change the implementation to take the mapping into account with:
@Override
protected boolean isJoinedFetchEnabled(AssociationType type, FetchMode config, CascadeStyle cascadeStyle) {
return isJoinedFetchEnabledInMapping( config, type ) &&
( cascadeStyle == null || cascadeStyle.doCascade( cascadeAction ) );
}
Your test then passes but I have a bunch of other obscure tests failing, because apparently, part of the code expects the collections to be eagerly loaded in the case of a merge (and there are other strange failures):
org.hibernate.test.bytecode.enhancement.merge.MergeEnhancedDetachedOrphanRemovalTest > testMergeDetachedNonEmptyCollection FAILED
javax.persistence.PersistenceException at MergeEnhancedDetachedOrphanRemovalTest.java:59
Caused by: org.hibernate.HibernateException at MergeEnhancedDetachedOrphanRemovalTest.java:59
org.hibernate.test.bytecode.enhancement.merge.MergeEnhancedDetachedOrphanRemovalTest > testMergeDetachedOrphanRemoval FAILED
javax.persistence.PersistenceException at MergeEnhancedDetachedOrphanRemovalTest.java:39
Caused by: org.hibernate.HibernateException at MergeEnhancedDetachedOrphanRemovalTest.java:39
org.hibernate.test.ops.MergeMultipleEntityCopiesAllowedLoggedTest > testCascadeFromDetachedToGT2DirtyRepresentations FAILED
java.lang.AssertionError
org.hibernate.test.ops.MergeMultipleEntityCopiesAllowedTest > testCascadeFromDetachedToGT2DirtyRepresentations FAILED
java.lang.AssertionError at MergeMultipleEntityCopiesAllowedTest.java:616
org.hibernate.test.event.collection.detached.MergeCollectionEventTest > testCollectionEventHandlingOnMerge FAILED
java.lang.AssertionError at MergeCollectionEventTest.java:156
org.hibernate.test.event.collection.detached.DetachedMultipleCollectionChangeTest > testMergeMultipleCollectionChangeEvents FAILED
java.lang.AssertionError at DetachedMultipleCollectionChangeTest.java:228
org.hibernate.test.readonly.ReadOnlySessionLazyNonLazyTest > testExistingModifiableAfterSetSessionReadOnly FAILED
java.lang.AssertionError at ReadOnlySessionLazyNonLazyTest.java:1364
What worries me is that, if these tests fail when not loading the collection eagerly via a join, then I suppose they would fail if the collection involved was not the first one (as only the first one is loaded eagerly via a join). |