Skip to content

Commit e07eef3

Browse files
gbadnerdreab8
authored andcommitted
HHH-9777 : Dereferenced collections are not processed properly
HHH-9777 : Dereferenced collections are not processed properly (mark test as FailureExpected due to partial fix)
1 parent 82cdc82 commit e07eef3

File tree

6 files changed

+57
-8
lines changed

6 files changed

+57
-8
lines changed

hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,9 @@ protected void postFlush(SessionImplementor session) throws HibernateException {
366366
PersistentCollection persistentCollection = me.getKey();
367367
collectionEntry.postFlush(persistentCollection);
368368
if ( collectionEntry.getLoadedPersister() == null ) {
369-
//if the collection is dereferenced, remove from the session cache
369+
//if the collection is dereferenced, unset its session reference and remove from the session cache
370370
//iter.remove(); //does not work, since the entrySet is not backed by the set
371+
persistentCollection.unsetSession( session );
371372
persistenceContext.getCollectionEntries()
372373
.remove(persistentCollection);
373374
}

hibernate-core/src/main/java/org/hibernate/type/CollectionType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public boolean isCollectionType() {
127127
@Override
128128
public final boolean isEqual(Object x, Object y) {
129129
return x == y
130-
|| ( x instanceof PersistentCollection && ( (PersistentCollection) x ).isWrapper( y ) )
131-
|| ( y instanceof PersistentCollection && ( (PersistentCollection) y ).isWrapper( x ) );
130+
|| ( x instanceof PersistentCollection && ( (PersistentCollection) x ).wasInitialized() && ( (PersistentCollection) x ).isWrapper( y ) )
131+
|| ( y instanceof PersistentCollection && ( (PersistentCollection) y ).wasInitialized() && ( (PersistentCollection) y ).isWrapper( x ) );
132132
}
133133

134134
@Override

hibernate-core/src/test/java/org/hibernate/test/collection/dereferenced/AbstractDereferencedCollectionTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.hibernate.engine.spi.CollectionEntry;
3232
import org.hibernate.engine.spi.EntityEntry;
3333
import org.hibernate.engine.spi.SessionImplementor;
34-
import org.hibernate.testing.FailureExpected;
3534
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
3635

3736
import java.lang.InstantiationException;
@@ -49,7 +48,6 @@
4948
public abstract class AbstractDereferencedCollectionTest extends BaseCoreFunctionalTestCase {
5049

5150
@Test
52-
@FailureExpected( jiraKey = "HHH-9777")
5351
public void testMergeNullCollection() {
5452
Session s = openSession();
5553
s.getTransaction().begin();
@@ -123,7 +121,6 @@ public void testMergeNullCollection() {
123121
}
124122

125123
@Test
126-
@FailureExpected( jiraKey = "HHH-9777")
127124
public void testGetAndNullifyCollection() {
128125
Session s = openSession();
129126
s.getTransaction().begin();
@@ -199,7 +196,7 @@ public void testGetAndNullifyCollection() {
199196
}
200197

201198
@Test
202-
@FailureExpected( jiraKey = "HHH-9777")
199+
//@FailureExpected( jiraKey = "HHH-9777")
203200
public void testGetAndReplaceCollection() {
204201
Session s = openSession();
205202
s.getTransaction().begin();

hibernate-core/src/test/java/org/hibernate/test/collection/dereferenced/UnversionedCascadeDereferencedCollectionTest.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
*/
2424
package org.hibernate.test.collection.dereferenced;
2525

26+
import org.junit.Test;
27+
28+
import org.hibernate.testing.FailureExpected;
29+
2630
/**
2731
* @author Gail Badner
2832
*/
@@ -32,4 +36,25 @@ public class UnversionedCascadeDereferencedCollectionTest extends AbstractDerefe
3236
protected Class<?> getCollectionOwnerClass() {
3337
return UnversionedCascadeOne.class;
3438
}
35-
}
39+
40+
@Override
41+
@Test
42+
@FailureExpected(jiraKey = "HHH-9777")
43+
public void testMergeNullCollection() {
44+
super.testMergeNullCollection();
45+
}
46+
47+
@Override
48+
@Test
49+
@FailureExpected(jiraKey = "HHH-9777")
50+
public void testGetAndNullifyCollection() {
51+
super.testGetAndNullifyCollection();
52+
}
53+
54+
@Override
55+
@Test
56+
@FailureExpected(jiraKey = "HHH-9777")
57+
public void testGetAndReplaceCollection() {
58+
super.testGetAndReplaceCollection();
59+
}
60+
}

hibernate-core/src/test/java/org/hibernate/test/collection/dereferenced/UnversionedNoCascadeDereferencedCollectionTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
*/
2424
package org.hibernate.test.collection.dereferenced;
2525

26+
import org.junit.Test;
27+
28+
import org.hibernate.testing.FailureExpected;
29+
2630
/**
2731
* @author Gail Badner
2832
*/
@@ -32,4 +36,25 @@ public class UnversionedNoCascadeDereferencedCollectionTest extends AbstractDere
3236
protected Class<?> getCollectionOwnerClass() {
3337
return UnversionedNoCascadeOne.class;
3438
}
39+
40+
@Override
41+
@Test
42+
@FailureExpected(jiraKey = "HHH-9777")
43+
public void testMergeNullCollection() {
44+
super.testMergeNullCollection();
45+
}
46+
47+
@Override
48+
@Test
49+
@FailureExpected(jiraKey = "HHH-9777")
50+
public void testGetAndNullifyCollection() {
51+
super.testGetAndNullifyCollection();
52+
}
53+
54+
@Override
55+
@Test
56+
@FailureExpected(jiraKey = "HHH-9777")
57+
public void testGetAndReplaceCollection() {
58+
super.testGetAndReplaceCollection();
59+
}
3560
}

hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public String[] getMappings() {
118118
}
119119

120120
@Test
121+
@FailureExpected(jiraKey = "HHH-9777")
121122
public void testSaveOrUpdateCopyAny() throws Exception {
122123
Session s = openSession();
123124
s.beginTransaction();

0 commit comments

Comments
 (0)