#996 Add findOne() and findOneOrEmpty()

This commit is contained in:
rob bygrave committed 2017-05-19 23:38:40 +12:00
1 parent c1bed9f578
commit db298a349e
20 files changed
+78 -51

No files matched your search

@@ -1,31 +1,6 @@
package io.ebeaninternal.api;
import io.ebean.AutoTune;
import io.ebean.BackgroundExecutor;
import io.ebean.BeanState;
import io.ebean.CallableSql;
import io.ebean.DocumentStore;
import io.ebean.ExpressionFactory;
import io.ebean.Filter;
import io.ebean.FutureIds;
import io.ebean.FutureList;
import io.ebean.FutureRowCount;
import io.ebean.PagedList;
import io.ebean.PersistenceContextScope;
import io.ebean.Query;
import io.ebean.QueryIterator;
import io.ebean.SqlQuery;
import io.ebean.SqlRow;
import io.ebean.SqlUpdate;
import io.ebean.Transaction;
import io.ebean.TransactionCallback;
import io.ebean.TxCallable;
import io.ebean.TxRunnable;
import io.ebean.TxScope;
import io.ebean.Update;
import io.ebean.UpdateQuery;
import io.ebean.ValuePair;
import io.ebean.Version;
import io.ebean.*;
import io.ebean.bean.BeanCollection;
import io.ebean.bean.CallStack;
import io.ebean.bean.EntityBeanIntercept;
@@ -43,7 +18,6 @@ import io.ebeaninternal.server.core.timezone.DataTimeZone;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.query.CQuery;
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
import io.ebean.TxIsolation;
import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceException;
@@ -51,6 +25,7 @@ import java.lang.reflect.Type;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -565,6 +540,16 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
return null;
}
@Override
public <T> T findOne(Query<T> query, Transaction transaction) {
return null;
}
@Override
public <T> Optional<T> findOneOrEmpty(Query<T> query, Transaction transaction) {
return null;
}
@Override
public <T> T findUnique(Query<T> query, Transaction transaction) {
return null;
@@ -27,7 +27,7 @@ public class WriteJsonDirtyTest {
Customer customer = Ebean.find(Customer.class).setId(customers.get(0).getId())
.setUseCache(false)
.findUnique();
.findOne();
SpiEbeanServer server = (SpiEbeanServer) Ebean.getServer(null);
BeanDescriptor<Customer> descriptor = server.getBeanDescriptor(Customer.class);
@@ -54,7 +54,7 @@ public class JdbcTransactionTest {
contactNatKeyCache.getStatistics(true);
Customer.find.byId(19898989);
Ebean.find(Contact.class).where().eq("email", "junk@foo.com").findUnique();
Ebean.find(Contact.class).where().eq("email", "junk@foo.com").findOne();
assertThat(customerBeanCache.getStatistics(true).getMissCount()).isEqualTo(1);
assertThat(contactNatKeyCache.getStatistics(true).getMissCount()).isEqualTo(1);
@@ -64,7 +64,7 @@ public class JdbcTransactionTest {
// these don't hit L2 cache due to the save of b1
Customer.find.byId(29898989);
Ebean.find(Contact.class).where().eq("email", "junk2@foo.com").findUnique();
Ebean.find(Contact.class).where().eq("email", "junk2@foo.com").findOne();
assertThat(customerBeanCache.getStatistics(true).getMissCount()).isEqualTo(0);
assertThat(contactNatKeyCache.getStatistics(true).getMissCount()).isEqualTo(0);