mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1424 - Deprecate / Move ... finder methods that take explicit transaction to ExtendedServer API
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package io.ebean;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ExtendedServerTest extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void findList() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
Query<Customer> query = server.find(Customer.class)
|
||||
.where().startsWith("name", "Rob")
|
||||
.query();
|
||||
|
||||
// rather than use .findList() return the query
|
||||
// when we use findList() .. it obtains a transaction using
|
||||
// the normal mechanism
|
||||
|
||||
// obtain a transaction somehow ...
|
||||
// for this test/example we just begin one
|
||||
try (Transaction transaction = server.beginTransaction()) {
|
||||
|
||||
// obtain extended API ... such that we can execute the
|
||||
// query using an explicit transaction
|
||||
List<Customer> customers = server.extended().findList(query, transaction);
|
||||
|
||||
assertThat(customers).isNotEmpty();
|
||||
transaction.commit();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import io.ebean.CallableSql;
|
||||
import io.ebean.DocumentStore;
|
||||
import io.ebean.DtoQuery;
|
||||
import io.ebean.ExpressionFactory;
|
||||
import io.ebean.ExtendedServer;
|
||||
import io.ebean.Filter;
|
||||
import io.ebean.FutureIds;
|
||||
import io.ebean.FutureList;
|
||||
@@ -79,6 +80,11 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtendedServer extended() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiLogManager log() {
|
||||
return null;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package io.ebeaninternal.server.query;
|
||||
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
import org.tests.model.basic.Order;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Order;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class LimitOffsetPagedListTest {
|
||||
public class LimitOffsetPagedListTest extends BaseTestCase {
|
||||
|
||||
private EbeanServer server = Ebean.getDefaultServer();
|
||||
private SpiEbeanServer server = spiEbeanServer();
|
||||
|
||||
@Test
|
||||
public void getPageIndex_when_firstRowsZero() throws Exception {
|
||||
public void getPageIndex_when_firstRowsZero() {
|
||||
assertEquals(limit(0, 10).getPageIndex(), 0);
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ public class LimitOffsetPagedListTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPageIndex_when_1_10() throws Exception {
|
||||
public void getPageIndex_when_1_10() {
|
||||
assertEquals(limit(1, 10).getPageIndex(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPageIndex_when_9_10() throws Exception {
|
||||
public void getPageIndex_when_9_10() {
|
||||
assertEquals(limit(1, 10).getPageIndex(), 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user