mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-24 15:55:55 +00:00
#722 - NotifyOfCommit failed. L2 Cache potentially not notified. - NullPointerException at BeanDescriptorCacheHelp.java:299
This commit is contained in:
@@ -278,7 +278,9 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
void manyPropPut(BeanPropertyAssocMany<?> many, Object details, Object parentId) {
|
||||
|
||||
CachedManyIds entry = createManyIds(many, details);
|
||||
cachePutManyIds(parentId, many.getName(), entry);
|
||||
if (entry != null) {
|
||||
cachePutManyIds(parentId, many.getName(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
void cachePutManyIds(Object parentId, String manyName, CachedManyIds entry) {
|
||||
@@ -296,6 +298,9 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
|
||||
List<Object> idList = new ArrayList<Object>();
|
||||
Collection<?> actualDetails = BeanCollectionUtil.getActualEntries(details);
|
||||
if (actualDetails == null) {
|
||||
return null;
|
||||
}
|
||||
for (Object bean : actualDetails) {
|
||||
idList.add(targetDescriptor.getId((EntityBean) bean));
|
||||
}
|
||||
@@ -621,7 +626,9 @@ final class BeanDescriptorCacheHelp<T> {
|
||||
BeanPropertyAssocMany<?> many = manyCollections.get(i);
|
||||
Object details = many.getValue(updateRequest.getEntityBean());
|
||||
CachedManyIds entry = createManyIds(many, details);
|
||||
changeSet.addManyPut(desc, many.getName(), id, entry);
|
||||
if (entry != null) {
|
||||
changeSet.addManyPut(desc, many.getName(), id, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.avaje.tests.cache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
@@ -240,4 +241,37 @@ public class TestCacheCollectionIds extends BaseTestCase {
|
||||
Assert.assertEquals(1, result.getCountries().size());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdating_noChange() throws InterruptedException {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Ebean.beginTransaction();
|
||||
try {
|
||||
|
||||
OCachedBean cachedBean = new OCachedBean();
|
||||
cachedBean.setName("helloForUpdate");
|
||||
Ebean.save(cachedBean);
|
||||
|
||||
cachedBean = Ebean.find(OCachedBean.class, cachedBean.getId());
|
||||
|
||||
cachedBean.setName("mod");
|
||||
ArrayList<Country> list = new ArrayList<Country>();
|
||||
list.add(Ebean.find(Country.class, "NZ"));
|
||||
cachedBean.setCountries(list);
|
||||
Ebean.save(cachedBean);
|
||||
|
||||
|
||||
cachedBean.setName("mod2");
|
||||
Ebean.save(cachedBean);
|
||||
|
||||
Ebean.commitTransaction();
|
||||
} finally {
|
||||
Ebean.endTransaction();
|
||||
}
|
||||
|
||||
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class OCachedBean {
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToMany
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
List<Country> countries = new ArrayList<Country>();
|
||||
|
||||
@OneToMany(mappedBy = "cachedBean", cascade = CascadeType.ALL)
|
||||
|
||||
Reference in New Issue
Block a user