mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Remove PersistenceContextScope.NONE for now
This commit is contained in:
+1
-12
@@ -48,15 +48,6 @@ public class TestPersistenceContextQueryScope extends BaseTestCase {
|
||||
.setPersistenceContextScope(QUERY)
|
||||
.findUnique();
|
||||
|
||||
// NONE scope also hits the DB
|
||||
// ... also explicitly not use bean cache
|
||||
EBasicVer bean4 = Ebean.find(EBasicVer.class)
|
||||
.setId(bean.getId())
|
||||
.setUseCache(false) // ignore L2 cache
|
||||
.setPersistenceContextScope(NONE)
|
||||
.findUnique();
|
||||
|
||||
|
||||
// TRANsACTION scope ... same as bean2 and does not hit the DB
|
||||
EBasicVer bean5 = Ebean.find(EBasicVer.class)
|
||||
.setId(bean.getId())
|
||||
@@ -72,9 +63,7 @@ public class TestPersistenceContextQueryScope extends BaseTestCase {
|
||||
assertSame(bean1, bean5);
|
||||
|
||||
assertEquals("second", bean3.getName());
|
||||
assertEquals("second", bean4.getName());
|
||||
|
||||
Ebean.delete(bean4);
|
||||
Ebean.delete(bean3);
|
||||
|
||||
Ebean.commitTransaction();
|
||||
|
||||
|
||||
+3
-32
@@ -13,40 +13,11 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.avaje.ebean.PersistenceContextScope.QUERY;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TestPersistencContextNone extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test_persistenceContextScopeNone() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
|
||||
List<Order> orders = Ebean.find(Order.class)
|
||||
.setPersistenceContextScope(PersistenceContextScope.NONE)
|
||||
.fetch("customer", "id, name")
|
||||
.where().istartsWith("customer.name", "rob").eq("customer.id", 1)
|
||||
.orderBy().asc("customer.name")
|
||||
.findList();
|
||||
|
||||
assertTrue(!orders.isEmpty());
|
||||
|
||||
// collect the customer instances
|
||||
List<Customer> customers = new ArrayList<Customer>();
|
||||
Set<Integer> identities = new HashSet<Integer>();
|
||||
|
||||
for (Order order : orders) {
|
||||
Customer customer = order.getCustomer();
|
||||
identities.add(System.identityHashCode(customer));
|
||||
customers.add(customer);
|
||||
}
|
||||
|
||||
// Many instances of 'logically the same Customer'
|
||||
assertTrue(identities.size() > 1);
|
||||
assertEquals(identities.size(), customers.size());
|
||||
}
|
||||
public class TestPersistenceContextScopeUsingOrders extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test_persistenceContextScopeQuery() {
|
||||
@@ -55,7 +26,7 @@ public class TestPersistencContextNone extends BaseTestCase {
|
||||
|
||||
List<Order> orders = Ebean.find(Order.class)
|
||||
// Use QUERY or TRANSACTION scope (just not NONE)
|
||||
.setPersistenceContextScope(PersistenceContextScope.QUERY)
|
||||
.setPersistenceContextScope(QUERY)
|
||||
.fetch("customer", "id, name")
|
||||
.where().istartsWith("customer.name", "rob").eq("customer.id", 1)
|
||||
.orderBy().asc("customer.name")
|
||||
Reference in New Issue
Block a user