use of org.hibernate.event.spi.MergeContext in project hibernate-orm by hibernate.
the class MergeContextTest method testMergeToManagedEntityFillFollowedByIterateEntrySet.
@Test
public void testMergeToManagedEntityFillFollowedByIterateEntrySet() {
MergeContext cache = new MergeContext(session, new DoNothingEntityCopyObserver());
Object mergeEntity = new Simple(1);
Object managedEntity = new Simple(2);
cache.put(mergeEntity, managedEntity, true);
checkCacheConsistency(cache, 1);
Iterator it = cache.entrySet().iterator();
assertTrue(it.hasNext());
Map.Entry entry = (Map.Entry) it.next();
assertSame(mergeEntity, entry.getKey());
assertSame(managedEntity, entry.getValue());
assertFalse(it.hasNext());
}
use of org.hibernate.event.spi.MergeContext in project hibernate-orm by hibernate.
the class MergeContextTest method testMergeToManagedEntityFillFollowedByModifyValues.
@Test
public void testMergeToManagedEntityFillFollowedByModifyValues() {
MergeContext cache = new MergeContext(session, new DoNothingEntityCopyObserver());
Object mergeEntity = new Simple(1);
Object managedEntity = new Simple(2);
cache.put(mergeEntity, managedEntity, true);
Iterator it = cache.values().iterator();
try {
it.remove();
fail("should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// expected
}
try {
cache.values().remove(managedEntity);
fail("should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// expected
}
Object newmanagedEntity = new Simple(3);
try {
cache.values().add(newmanagedEntity);
fail("should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// expected
}
}
use of org.hibernate.event.spi.MergeContext in project hibernate-orm by hibernate.
the class MergeContextTest method testMergeToManagedEntityFillFollowedByModifyKeys.
@Test
public void testMergeToManagedEntityFillFollowedByModifyKeys() {
MergeContext cache = new MergeContext(session, new DoNothingEntityCopyObserver());
Object mergeEntity = new Simple(1);
Object managedEntity = new Simple(2);
cache.put(mergeEntity, managedEntity, true);
Iterator it = cache.keySet().iterator();
try {
it.remove();
fail("should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// expected
}
try {
cache.keySet().remove(mergeEntity);
fail("should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// expected
}
Object newmanagedEntity = new Simple(3);
try {
cache.keySet().add(newmanagedEntity);
fail("should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException ex) {
// expected
}
}
use of org.hibernate.event.spi.MergeContext in project hibernate-orm by hibernate.
the class MergeContextTest method testReplaceManagedEntity.
@Test
public void testReplaceManagedEntity() {
MergeContext cache = new MergeContext(session, new DoNothingEntityCopyObserver());
Simple mergeEntity = new Simple(1);
Simple managedEntity = new Simple(0);
cache.put(mergeEntity, managedEntity);
Simple managedEntityNew = new Simple(0);
try {
cache.put(mergeEntity, managedEntityNew);
} catch (IllegalArgumentException ex) {
// expected; cannot replace the managed entity result for a particular merge entity.
}
}
Aggregations