mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-24 15:55:55 +00:00
#725 - L2 cache not updating CacheManyId's entry when Lazy loading on a ToMany relationship, after a prior update, when other ToMany is a vanilla type (like ArrayList)
This commit is contained in:
@@ -638,6 +638,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
if (v instanceof BeanCollection<?>) {
|
||||
BeanCollection<?> bc = (BeanCollection<?>) v;
|
||||
return bc.isReference() ? bc : null;
|
||||
} else if (v != null) {
|
||||
return null;
|
||||
} else {
|
||||
return createReference(parentBean);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.tests.model.basic.Contact;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class BeanPropertyAssocManyTest extends BaseTestCase {
|
||||
|
||||
BeanDescriptor<Customer> customerDesc = spiEbeanServer().getBeanDescriptor(Customer.class);
|
||||
|
||||
BeanPropertyAssocMany<Customer> contacts() {
|
||||
return (BeanPropertyAssocMany<Customer>)customerDesc.getBeanProperty("contacts");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createReferenceIfNull_when_notBeanCollection_expect_null() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.setContacts(new ArrayList<Contact>());
|
||||
|
||||
BeanCollection<?> ref = contacts().createReferenceIfNull((EntityBean) customer);
|
||||
assertNull(ref);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createReferenceIfNull_when_null_expect_ref() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.setContacts(null);
|
||||
|
||||
BeanCollection<?> ref = contacts().createReferenceIfNull((EntityBean) customer);
|
||||
assertNotNull(ref);
|
||||
assertTrue(ref.isReference());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user