#1114 - Deprecate findUnique() - please migrate to findOne() - update tests

This commit is contained in:
rob bygrave
2017-09-08 22:48:46 +12:00
parent 2470486f20
commit 8c0232fdb8
67 changed files with 128 additions and 128 deletions
@@ -76,7 +76,7 @@ public class EbeanServer_eqlTest extends BaseTestCase {
assertThat(query.getGeneratedSql()).endsWith("order by t0.name, t0.id limit 10 offset 3");
}
}
@Test
public void basic_limit_offset3() {
@@ -93,7 +93,7 @@ public class EbeanServer_eqlTest extends BaseTestCase {
assertThat(query.getGeneratedSql()).endsWith("order by t0.id limit 10 offset 3");
}
}
@Test
public void basic_limit_offset4() {
@@ -110,7 +110,7 @@ public class EbeanServer_eqlTest extends BaseTestCase {
assertThat(query.getGeneratedSql()).endsWith("order by t0.id limit 10");
}
}
@Test
public void orderBy_override() {
@@ -142,7 +142,7 @@ public class EbeanServer_eqlTest extends BaseTestCase {
public void unboundNamedParams_expect_PersistenceException() {
Query<Customer> query = server().createQuery(Customer.class, "where name = :name");
query.findUnique();
query.findOne();
}
@Test
@@ -178,7 +178,7 @@ public class EbeanServer_eqlTest extends BaseTestCase {
.setParameter("id", 1);
query.setUseCache(false);
query.findUnique();
query.findOne();
assertThat(query.getGeneratedSql()).contains("from o_customer t0 left join contact t1 on t1.customer_id = t0.id ");
}
@@ -193,7 +193,7 @@ public class EbeanServer_eqlTest extends BaseTestCase {
.setParameter("id", 1);
query.setUseCache(false);
query.findUnique();
query.findOne();
assertThat(query.getGeneratedSql()).contains("from o_customer t0 left join contact t1 on t1.customer_id = t0.id ");
}
@@ -25,7 +25,7 @@ public class TestQueryAdapter extends BaseTestCase {
Query<TOne> queryFindId = Ebean.find(TOne.class)
.setId(o.getId());
TOne one = queryFindId.findUnique();
TOne one = queryFindId.findOne();
Assert.assertNotNull(one);
Assert.assertEquals(one.getId(), o.getId());
String generatedSql = queryFindId.getGeneratedSql();
@@ -29,7 +29,7 @@ public class TestBasicClobFetchEager extends BaseTestCase {
// Clob included in fetch as FetchType.EAGER set by annotation
Query<EBasicClobFetchEager> defaultQuery = Ebean.find(EBasicClobFetchEager.class).setId(entity.getId());
defaultQuery.findUnique();
defaultQuery.findOne();
String sql = trimSql(defaultQuery.getGeneratedSql(), 6);
assertThat(sql).contains(expectedSql);
@@ -49,7 +49,7 @@ public class TestBasicClobFetchEager extends BaseTestCase {
// Explicitly select * including Clob
Query<EBasicClobFetchEager> explicitQuery = Ebean.find(EBasicClobFetchEager.class).setId(entity.getId()).select("*");
explicitQuery.findUnique();
explicitQuery.findOne();
sql = sqlOf(explicitQuery, 6);
assertThat(sql).contains(expectedSql);
@@ -31,7 +31,7 @@ public class TestBasicClobNoVer extends BaseTestCase {
// Clob by default is Fetch Lazy
Query<EBasicClobNoVer> defaultQuery = Ebean.find(EBasicClobNoVer.class).setId(entity.getId());
defaultQuery.findUnique();
defaultQuery.findOne();
String sql = sqlOf(defaultQuery, 2);
Assert.assertTrue("Clob is fetch lazy by default", sql.contains(sqlNoClob));
@@ -40,7 +40,7 @@ public class TestBasicClobNoVer extends BaseTestCase {
// Explicitly select * including Clob
Query<EBasicClobNoVer> explicitQuery = Ebean.find(EBasicClobNoVer.class).setId(entity.getId()).select("*");
explicitQuery.findUnique();
explicitQuery.findOne();
sql = sqlOf(explicitQuery, 2);
Assert.assertTrue("Explicitly include Clob", sql.contains(sqlWithClob));
@@ -94,7 +94,7 @@ public class TestEnumValueAnnotation extends BaseTestCase {
EBasicEnumInt b2 = Ebean.find(EBasicEnumInt.class)
.where().eq("id", b.getId())
.eq("status", EBasicEnumInt.Status.NEW)
.findUnique();
.findOne();
assertNotNull(b2);
}
@@ -29,7 +29,7 @@ public class TestExtraScalarTypes extends BaseTestCase {
Ebean.save(e);
ESomeType e2 = Ebean.find(ESomeType.class).setAutoTune(false).setId(e.getId()).findUnique();
ESomeType e2 = Ebean.find(ESomeType.class).setAutoTune(false).setId(e.getId()).findOne();
Assert.assertNotNull(e2.getCurrency());
Assert.assertNotNull(e2.getLocale());
@@ -22,7 +22,7 @@ public class TestSqlRowUUID extends BaseTestCase {
SqlQuery q = Ebean.createSqlQuery("select * from tuuid_entity where id = :id");
q.setParameter("id", e.getId());
SqlRow sqlRow = q.findUnique();
SqlRow sqlRow = q.findOne();
UUID id = sqlRow.getUUID("id");
@@ -34,7 +34,7 @@ public class TestBatchOnCascadeExceptionHandling extends BaseTestCase {
} catch (PersistenceException e) {
txn.getConnection().rollback(sp);
EBasicWithUniqueCon conflicting = server().find(EBasicWithUniqueCon.class).where().eq("name", "conflict").findUnique();
EBasicWithUniqueCon conflicting = server().find(EBasicWithUniqueCon.class).where().eq("name", "conflict").findOne();
assertThat(conflicting).isNotNull();
server().delete(conflicting);
server().save(v2); // try again
@@ -44,7 +44,7 @@ public class TestBatchOnCascadeExceptionHandling extends BaseTestCase {
txn.end();
}
EBasicWithUniqueCon winner = server().find(EBasicWithUniqueCon.class).where().eq("name", "conflict").findUnique();
EBasicWithUniqueCon winner = server().find(EBasicWithUniqueCon.class).where().eq("name", "conflict").findOne();
assertThat(winner).isNotNull();
assertThat(winner.getDescription()).isEqualTo("after");
}
@@ -27,7 +27,7 @@ public class TestBasicLazy extends BaseTestCase {
ResetBasicData.reset();
Order order = Ebean.find(Order.class).select("totalAmount").setMaxRows(1).order("id")
.findUnique();
.findOne();
Assert.assertNotNull(order);
@@ -45,7 +45,7 @@ public class TestBasicLazy extends BaseTestCase {
// safety check to see if our customer we are going to use for the test has
// some contacts
Customer c = Ebean.find(Customer.class).setId(1).findUnique();
Customer c = Ebean.find(Customer.class).setId(1).findOne();
Assert.assertNotNull(c.getContacts());
Assert.assertTrue("no contacts on test customer 1", !c.getContacts().isEmpty());
@@ -75,7 +75,7 @@ public class TestBasicLazy extends BaseTestCase {
ResetBasicData.reset();
Order order = Ebean.find(Order.class).select("totalAmount").setMaxRows(1).order("id")
.findUnique();
.findOne();
Assert.assertNotNull(order);
@@ -49,12 +49,12 @@ public class TestBatchLazyWithCacheHits extends BaseTestCase {
UUOne c = Ebean.find(UUOne.class)
.where().idEq(inserted.get(2).getId())
.findUnique();
.findOne();
assertNotNull(c);
UUOne c2 = Ebean.find(UUOne.class)
.where().idEq(inserted.get(2).getId())
.findUnique();
.findOne();
assertNotNull(c2);
statistics = beanCache.getStatistics(true);
assertEquals(statistics.getHitCount(), 1);
@@ -23,7 +23,7 @@ public class TestLoadOnDirty extends BaseTestCase {
Customer customer = Ebean.find(Customer.class).setId(custs.get(0).getId()).select("name")
.setUseCache(false)
.findUnique();
.findOne();
BeanState beanState = Ebean.getBeanState(customer);
Assert.assertTrue(!beanState.isNew());
@@ -65,7 +65,7 @@ public class TestLoadOnDirty extends BaseTestCase {
.setId(custs.get(0).getId())
.select("id")
.setUseCache(false)
.findUnique();
.findOne();
BeanState beanState = Ebean.getBeanState(customer);
beanState.setDisableLazyLoad(true);
@@ -23,7 +23,7 @@ public class TestSecondQueryNoRows extends BaseTestCase {
.setAutoTune(false)
.setId(cnew.getId())
.fetch("contacts", new FetchConfig().query())
.findUnique();
.findOne();
assertNotNull(c);
assertEquals(0, c.getContacts().size());
@@ -88,7 +88,7 @@ public class TestSecondaryQueries extends BaseTestCase {
SpiQuery<?> spiQuery = (SpiQuery<?>) query;
spiQuery.setLogSecondaryQuery(true);
Customer cust = query.findUnique();
Customer cust = query.findOne();
Assert.assertNotNull(cust);
String generatedSql = query.getGeneratedSql();
+1 -1
View File
@@ -35,7 +35,7 @@ public class TestBeanCache extends BaseTestCase {
// expect to hit the cache, no SQL
LoggedSqlCollector.start();
OCachedBean bean2 = Ebean.find(OCachedBean.class).setReadOnly(true).setId(String.valueOf(bean.getId())).findUnique();
OCachedBean bean2 = Ebean.find(OCachedBean.class).setReadOnly(true).setId(String.valueOf(bean.getId())).findOne();
sql = LoggedSqlCollector.stop();
assertNotNull(bean2);
assertThat(sql).isEmpty();
@@ -42,7 +42,7 @@ public class TestBeanCacheWithDeleteQuery extends BaseTestCase {
// expect not to hit the cache, expect SQL
LoggedSqlCollector.start();
OCachedBean bean2 = Ebean.find(OCachedBean.class).setReadOnly(true).setId(String.valueOf(bean.getId())).findUnique();
OCachedBean bean2 = Ebean.find(OCachedBean.class).setReadOnly(true).setId(String.valueOf(bean.getId())).findOne();
sql = LoggedSqlCollector.stop();
assertNull(bean2);
assertThat(sql).isNotEmpty();
@@ -72,7 +72,7 @@ public class TestBeanCacheWithDeleteQuery extends BaseTestCase {
// expect not to hit the cache, expect SQL
LoggedSqlCollector.start();
OCachedBean bean2 = Ebean.find(OCachedBean.class).setReadOnly(true).setId(String.valueOf(bean.getId())).findUnique();
OCachedBean bean2 = Ebean.find(OCachedBean.class).setReadOnly(true).setId(String.valueOf(bean.getId())).findOne();
sql = LoggedSqlCollector.stop();
assertNotNull(bean2);
assertThat(sql).isNotEmpty();
+2 -2
View File
@@ -103,7 +103,7 @@ public class TestCacheBasic extends BaseTestCase {
// Country c8 = Ebean.find(Country.class)
// .setId("NZ")
// .setReadOnly(false)
// .findUnique();
// .findOne();
//
// // Explicitly NOT readOnly
// Assert.assertFalse("NOT read only",Ebean.getBeanState(c8).isReadOnly());
@@ -118,7 +118,7 @@ public class TestCacheBasic extends BaseTestCase {
// Country c9 = Ebean.find(Country.class)
// .setReadOnly(false)
// .setId("NZ")
// .findUnique();
// .findOne();
//
// // Find loads cache ...
// Assert.assertFalse(Ebean.getBeanState(c9).isReadOnly());
@@ -28,14 +28,14 @@ public class TestCacheInterceptSaveWhenLazyLoaded extends BaseTestCase {
Order foundOrder = Ebean.find(Order.class)
.where().eq("id", order.getId())
.findUnique();
.findOne();
foundOrder.setStatus(Order.Status.APPROVED);
assertTrue(Ebean.getBeanState(foundOrder).isDirty());
Customer foundCustomer = Ebean.find(Customer.class)
.where().eq("id", customer.getId())
.findUnique();
.findOne();
// the foundOrder is in this list
foundCustomer.getOrders().size();
+3 -3
View File
@@ -35,11 +35,11 @@ public class TestCacheNaturalId extends BaseTestCase {
contactCache.getStatistics(true);
Contact c0 = Ebean.find(Contact.class).where().eq("email", emailToSearch).findUnique();
Contact c0 = Ebean.find(Contact.class).where().eq("email", emailToSearch).findOne();
ServerCacheStatistics stats0 = contactCache.getStatistics(false);
Contact c1 = Ebean.find(Contact.class).where().eq("email", emailToSearch).findUnique();
Contact c1 = Ebean.find(Contact.class).where().eq("email", emailToSearch).findOne();
ServerCacheStatistics stats1 = contactCache.getStatistics(false);
@@ -54,7 +54,7 @@ public class TestCacheNaturalId extends BaseTestCase {
awaitL2Cache();
Contact c2 = Ebean.find(Contact.class).where().eq("email", "mychangedemail@what.com")
.findUnique();
.findOne();
ServerCacheStatistics stats2 = contactCache.getStatistics(false);
@@ -42,9 +42,9 @@ public class TestL2CacheWithSharedBean extends BaseTestCase {
tunedInfo.tuneQuery((SpiQuery<?>) query);
query.findUnique(); // PUT into cache
query.findOne(); // PUT into cache
FeatureDescription fd2 = query.findUnique(); // LOAD cache
FeatureDescription fd2 = query.findOne(); // LOAD cache
fd2.getDescription(); // invoke lazy load (this fails)
@@ -21,13 +21,13 @@ public class TestCKeyDelete extends BaseTestCase {
Ebean.save(p);
CKeyParent found = Ebean.find(CKeyParent.class).where().idEq(searchId).findUnique();
CKeyParent found = Ebean.find(CKeyParent.class).where().idEq(searchId).findOne();
Assert.assertNotNull(found);
Ebean.delete(CKeyParent.class, searchId);
CKeyParent notFound = Ebean.find(CKeyParent.class).where().idEq(searchId).findUnique();
CKeyParent notFound = Ebean.find(CKeyParent.class).where().idEq(searchId).findOne();
Assert.assertNull(notFound);
@@ -66,7 +66,7 @@ public class TestCKeyIdInExpression extends BaseTestCase {
Query<ROrder> query2 = server.find(ROrder.class).setId(k0);
query2.findUnique();
query2.findOne();
sql = query2.getGeneratedSql();
Assert.assertTrue(sql.contains("t0.company = ? "));
Assert.assertTrue(sql.contains(" and t0.order_number = ?"));
@@ -58,7 +58,7 @@ public class TestCKeyLazyLoad extends BaseTestCase {
CKeyParentId searchId = new CKeyParentId(1, "one");
CKeyParent found = Ebean.find(CKeyParent.class).where().idEq(searchId).findUnique();
CKeyParent found = Ebean.find(CKeyParent.class).where().idEq(searchId).findOne();
assertNotNull(found);
assertEquals(2, found.getDetails().size());
@@ -134,7 +134,7 @@ public class TestCore extends BaseTestCase {
itemKey.setCustomer(2);
itemKey.setItemNumber("ITEM1");
Item item = server().find(Item.class).select("description").where().idEq(itemKey).findUnique();
Item item = server().find(Item.class).select("description").where().idEq(itemKey).findOne();
assertNotNull(item);
assertNotNull(item.getUnits());
assertEquals("P", item.getUnits());
@@ -27,7 +27,7 @@ public class TestDPersonIUD extends TestCase {
// DPerson p2 = Ebean.find(DPerson.class)
// .setAutoTune(false)
// .where().idEq(id)
// .findUnique();
// .findOne();
//
// Assert.assertNotNull(p2);
// System.out.println(p2);
@@ -30,7 +30,7 @@ public class DocLinkTest extends BaseTestCase {
Link link = Ebean.find(Link.class)
.setId(link1.getId())
.select("name")
.findUnique();
.findOne();
assertThat(link).isNotNull();
@@ -89,7 +89,7 @@ public class DocLinkTest extends BaseTestCase {
link1.save();
Ebean.getDefaultServer().publish(Link.class, link1.getId());
Link link = Ebean.find(Link.class).setId(link1.getId()).asDraft().findUnique();
Link link = Ebean.find(Link.class).setId(link1.getId()).asDraft().findOne();
Ebean.deletePermanent(link);
}
@@ -119,13 +119,13 @@ public class DocLinkTest extends BaseTestCase {
EbeanServer server = Ebean.getDefaultServer();
server.publish(Link.class, link1.getId());
link1 = Ebean.find(Link.class).setId(link1.getId()).asDraft().findUnique();
link1 = Ebean.find(Link.class).setId(link1.getId()).asDraft().findOne();
StrictAssertions.assertThat(link1.isDraft()).isTrue();
// this is a soft delete (no automatic publish here, only updates draft)
link1.delete();
Link live = Ebean.find(Link.class).setId(link1.getId()).findUnique();
Link live = Ebean.find(Link.class).setId(link1.getId()).findOne();
assertThat(live).isNotNull();
StrictAssertions.assertThat(live.isDraft()).isFalse();
StrictAssertions.assertThat(live.isDeleted()).isFalse(); // soft delete state not published yet
@@ -133,7 +133,7 @@ public class DocLinkTest extends BaseTestCase {
// this is a permanent delete (effectively has automatic publish)
server.deletePermanent(link1);
live = Ebean.find(Link.class).setId(link1.getId()).findUnique();
live = Ebean.find(Link.class).setId(link1.getId()).findOne();
assertThat(live).isNull();
}
@@ -168,7 +168,7 @@ public class DocLinkTest extends BaseTestCase {
link1.setWhenPublish(when);
link1.save();
Link draft1 = Ebean.find(Link.class).setId(link1.getId()).asDraft().findUnique();
Link draft1 = Ebean.find(Link.class).setId(link1.getId()).asDraft().findOne();
StrictAssertions.assertThat(draft1.isDirty()).isTrue();
EbeanServer server = Ebean.getDefaultServer();
@@ -177,7 +177,7 @@ public class DocLinkTest extends BaseTestCase {
StrictAssertions.assertThat(linkLive.getComment()).isEqualTo(comment);
StrictAssertions.assertThat(linkLive.getWhenPublish()).isEqualTo(when);
Link draft1b = Ebean.find(Link.class).setId(link1.getId()).asDraft().findUnique();
Link draft1b = Ebean.find(Link.class).setId(link1.getId()).asDraft().findOne();
StrictAssertions.assertThat(draft1b.isDirty()).isFalse();
StrictAssertions.assertThat(draft1b.getComment()).isNull();
StrictAssertions.assertThat(draft1b.getWhenPublish()).isNull();
@@ -209,7 +209,7 @@ public class DocLinkTest extends BaseTestCase {
Doc draftDoc1 = server.find(Doc.class)
.setId(doc1.getId())
.asDraft()
.findUnique();
.findOne();
assertThat(draftDoc1.getLinks()).hasSize(2);
@@ -250,7 +250,7 @@ public class DocLinkTest extends BaseTestCase {
Link draftLink = Ebean.find(Link.class)
.setId(link1.getId())
.asDraft()
.findUnique();
.findOne();
draftLink.setLocation("secondLocation");
draftLink.save();
@@ -260,7 +260,7 @@ public class DocLinkTest extends BaseTestCase {
draftLink = Ebean.find(Link.class)
.setId(link1.getId())
.asDraft()
.findUnique();
.findOne();
StrictAssertions.assertThat(draftLink.getLocation()).isEqualTo("firstLocation");
@@ -281,7 +281,7 @@ public class DocLinkTest extends BaseTestCase {
Link draftLink = Ebean.find(Link.class)
.setId(link1.getId())
.asDraft()
.findUnique();
.findOne();
draftLink.setLocation("secondLocation");
draftLink.setComment("A good change");
@@ -41,13 +41,13 @@ public class OrganisationTest {
Document draftDoc = server.find(Document.class)
.asDraft()
.setId(doc.getId())
.findUnique();
.findOne();
assertNotNull(draftDoc);
Document liveDoc = server.find(Document.class)
.setId(doc.getId())
.findUnique();
.findOne();
assertNull(liveDoc);
@@ -81,7 +81,7 @@ public class OrganisationTest {
server.publish(Document.class, doc.getId(), null);
Document fetchDoc = Ebean.find(Document.class).setId(doc.getId()).asDraft().findUnique();
Document fetchDoc = Ebean.find(Document.class).setId(doc.getId()).asDraft().findOne();
List<DocumentMedia> media = fetchDoc.getMedia();
assertThat(media.size()).isEqualTo(2);
@@ -96,8 +96,8 @@ public class TestInheritance extends BaseTestCase {
// Test setup complete, so retrieve bean from db
//grandparent1 = server().find(GrandParentPerson.class).setId(grandparent1.getIdentifier()).where()
// .in("effectiveBean.id",2,null) // geht nicht!
// .findUnique();
parent1 = server().find(ParentPerson.class).setId(1).fetch("someBean").findUnique();
// .findOne();
parent1 = server().find(ParentPerson.class).setId(1).fetch("someBean").findOne();
assertEquals("A Bean", parent1.getSomeBean().getName());
grandparent1 = server().find(GrandParentPerson.class)
.fetch("children", "*") // FIXME If I do not fetch childrenBean, I will get an exception
@@ -109,7 +109,7 @@ public class TestInheritance extends BaseTestCase {
.in("effectiveBean.id", 1)
.isNull("effectiveBean.id")
.endOr()
.findUnique();
.findOne();
assertNotNull(grandparent1);
// check if aggregation works
@@ -186,7 +186,7 @@ public class TestInheritance extends BaseTestCase {
assertNull(child3.getEffectiveBean());
// Now start from bottom up
child2 = server().find(ChildPerson.class).where().eq("name", "Julia").select("parent.name").findUnique();
child2 = server().find(ChildPerson.class).where().eq("name", "Julia").select("parent.name").findOne();
assertEquals("Baz", child2.getEffectiveFamilyName());
assertEquals("Munich", child2.getEffectiveAddress());
assertNull(child2.getSomeBean());
@@ -76,11 +76,11 @@ public class TestHistoryInsert extends BaseTestCase {
logger.info("-- delete");
Ebean.delete(user);
User earlyVersion = Ebean.find(User.class).setId(user.getId()).asOf(afterInsert).findUnique();
User earlyVersion = Ebean.find(User.class).setId(user.getId()).asOf(afterInsert).findOne();
assertThat(earlyVersion.getName()).isEqualTo("Jim");
assertThat(earlyVersion.getEmail()).isEqualTo("one@email.com");
Ebean.find(User.class).setId(user.getId()).asOf(afterInsert).findUnique();
Ebean.find(User.class).setId(user.getId()).asOf(afterInsert).findOne();
logger.info("-- last fetchHistory");
@@ -111,7 +111,7 @@ public class TestInheritInsert extends BaseTestCase {
.eq("id", car.getId())
.query();
Car result = query.findUnique();
Car result = query.findOne();
assertThat(query.getGeneratedSql()).contains("order by t0.id, t2.location_code");
assertThat(query.getGeneratedSql()).contains("left join car_fuse t2 on t2.id = t1.fuse_id");
@@ -107,7 +107,7 @@ public class TestInheritanceJoins extends BaseTestCase {
server.save(configurations);
Configurations configurationsQueried = server.find(Configurations.class).fetch("groupConfigurations").where().idEq(configurations.getId()).findUnique();
Configurations configurationsQueried = server.find(Configurations.class).fetch("groupConfigurations").where().idEq(configurations.getId()).findOne();
Assert.assertNotNull(configurationsQueried);
}
@@ -23,13 +23,13 @@ public class TestInheritanceCache extends BaseTestCase {
CInhRoot gotOne = Ebean.find(CInhRoot.class)
.setId(one.getId())
.findUnique();
.findOne();
assertThat(gotOne).isInstanceOf(CInhOne.class);
CInhRoot gotOneFromCache = Ebean.find(CInhRoot.class)
.setId(one.getId())
.findUnique();
.findOne();
assertThat(gotOneFromCache).isInstanceOf(CInhOne.class);
@@ -21,7 +21,7 @@ public class TestInsertQueryUpdate extends BaseTestCase {
EBasicVer e1 = Ebean.find(EBasicVer.class)
.select("name")
.setId(e0.getId())
.findUnique();
.findOne();
BeanState beanState = Ebean.getBeanState(e1);
Set<String> loadedProps = beanState.getLoadedProps();
@@ -99,7 +99,7 @@ public class TestJsonNodeBasic extends BaseTestCase {
EBasicJsonNode bean1 = Ebean.find(EBasicJsonNode.class)
.select("name")
.setId(bean.getId())
.findUnique();
.findOne();
Set<String> loadedProps = Ebean.getBeanState(bean1).getLoadedProps();
assertTrue(loadedProps.contains("name"));
@@ -56,7 +56,7 @@ public class TestJsonNodeBlob extends BaseTestCase {
EBasicJsonNodeBlob bean1 = Ebean.find(EBasicJsonNodeBlob.class)
.select("name")
.setId(bean.getId())
.findUnique();
.findOne();
Set<String> loadedProps = Ebean.getBeanState(bean1).getLoadedProps();
assertTrue(loadedProps.contains("name"));
@@ -56,7 +56,7 @@ public class TestJsonNodeJsonb extends BaseTestCase {
EBasicJsonNodeJsonB bean1 = Ebean.find(EBasicJsonNodeJsonB.class)
.select("name")
.setId(bean.getId())
.findUnique();
.findOne();
Set<String> loadedProps = Ebean.getBeanState(bean1).getLoadedProps();
assertTrue(loadedProps.contains("name"));
@@ -56,7 +56,7 @@ public class TestJsonNodeVarchar extends BaseTestCase {
EBasicJsonNodeVarchar bean1 = Ebean.find(EBasicJsonNodeVarchar.class)
.select("name")
.setId(bean.getId())
.findUnique();
.findOne();
Set<String> loadedProps = Ebean.getBeanState(bean1).getLoadedProps();
assertTrue(loadedProps.contains("name"));
@@ -33,7 +33,7 @@ public class TestM2MDeleteCascadeFromParent extends BaseTestCase {
Ebean.save(c0);
SqlQuery sqlQuery = Ebean.createSqlQuery("select count(*) as count from mny_b_mny_c");
SqlRow unique = sqlQuery.findUnique();
SqlRow unique = sqlQuery.findOne();
assertEquals(Long.valueOf(1), unique.getLong("count"));
@@ -25,7 +25,7 @@ public class CustomerFinder extends Finder<Integer, Customer> {
@Nullable
public Customer byName(String name) {
return query().where().eq("name", name).findUnique();
return query().where().eq("name", name).findOne();
}
public List<Customer> byNameStatus(String nameStartsWith, Customer.Status status) {
@@ -61,7 +61,7 @@ public class TestDeleteUnloadedChildren extends BaseTestCase {
Ebean.beginTransaction();
try {
EdParent parent = Ebean.find(EdParent.class).where().eq("name", "MyComputer").findUnique();
EdParent parent = Ebean.find(EdParent.class).where().eq("name", "MyComputer").findOne();
// // Works only if the following statement is included
// int x = parent.getChildren().size();
Ebean.delete(parent);
@@ -79,7 +79,7 @@ public class TestDeleteUnloadedChildren extends BaseTestCase {
Ebean.beginTransaction();
try {
EdExtendedParent extendedParent = Ebean.find(EdExtendedParent.class).where()
.eq("name", "My second computer").findUnique();
.eq("name", "My second computer").findOne();
extendedParent.getChildren().size();
Ebean.delete(extendedParent);
Ebean.commitTransaction();
@@ -82,7 +82,7 @@ public class Document extends BaseDomain {
}
public Document asDraft(Long id) {
return query().asDraft().setId(id).findUnique();
return query().asDraft().setId(id).findOne();
}
}
}
@@ -43,7 +43,7 @@ public class TestHistoryExclude extends BaseTestCase {
HeLink linkFound = Ebean.find(HeLink.class)
.asOf(new Timestamp(System.currentTimeMillis()))
.setId(link.getId())
.findUnique();
.findOne();
assertThat(linkFound.getDocs().size()).isEqualTo(2);
}
@@ -43,7 +43,7 @@ public class TestHistoryInclude extends BaseTestCase {
HiLink linkFound = Ebean.find(HiLink.class)
.asOf(new Timestamp(System.currentTimeMillis()))
.setId(link.getId())
.findUnique();
.findOne();
assertThat(linkFound.getDocs().size()).isEqualTo(2);
}
@@ -26,7 +26,7 @@ public class TestMediaInheritanceJoinToMany extends BaseTestCase {
Query<MProfile> query = Ebean.find(MProfile.class).fetch("picture").where().eq("name", name).query();
// assert we get the profile with a null picture
MProfile profile = query.findUnique();
MProfile profile = query.findOne();
Assert.assertNotNull(profile);
// select t0.id c0, t0.name c1, t1.type c2, t1.id c3, t1.url c4, t1.note c5
@@ -87,7 +87,7 @@ public class TestOneToOneOptionalRelationship extends BaseTestCase {
LoggedSqlCollector.start();
Account fetchedAccount = Account.find.query().fetch("user").setId(account.getId()).findUnique();
Account fetchedAccount = Account.find.query().fetch("user").setId(account.getId()).findOne();
Assert.assertNotNull(fetchedAccount);
Assert.assertNotNull(fetchedAccount.getUser());
@@ -51,7 +51,7 @@ public class DeleteById_SoftDelete_Tests extends BaseTestCase {
Cover cover1 = Ebean.find(Cover.class)
.setIncludeSoftDeletes()
.setId(cover.getId())
.findUnique();
.findOne();
cover1.setDeleted(false);
@@ -40,7 +40,7 @@ public class TestOneToOneHardDelete extends BaseTestCase {
assertThat(sql.get(1)).contains("update album set deleted=?, last_update=? where id=?");
assertThat(sql.get(2)).contains("update cover set deleted=? where id=?");
Album found2 = Album.find.query().setId(album.getId()).setIncludeSoftDeletes().findUnique();
Album found2 = Album.find.query().setId(album.getId()).setIncludeSoftDeletes().findOne();
LoggedSqlCollector.start();
@@ -46,7 +46,7 @@ public class TestOrderByFetch extends BaseTestCase {
.fetch("categories")
.fetch("categories.groups")
.fetch("categories.groups.questions")
.findUnique();
.findOne();
assertEquals(1, foundSurvey.getCategories().size());
@@ -38,7 +38,7 @@ public class TestPersistenceContextQueryScope extends BaseTestCase {
EBasicVer bean2 = Ebean.find(EBasicVer.class)
.setId(bean.getId())
.setUseCache(false) // ignore L2 cache
.findUnique();
.findOne();
// QUERY scope hits the DB (doesn't use the existing transactions persistence context)
// ... also explicitly not use bean cache
@@ -46,14 +46,14 @@ public class TestPersistenceContextQueryScope extends BaseTestCase {
.setId(bean.getId())
.setUseCache(false) // ignore L2 cache
.setPersistenceContextScope(QUERY)
.findUnique();
.findOne();
// TRANsACTION scope ... same as bean2 and does not hit the DB
EBasicVer bean5 = Ebean.find(EBasicVer.class)
.setId(bean.getId())
.setUseCache(false) // ignore L2 cache
.setPersistenceContextScope(TRANSACTION)
.findUnique();
.findOne();
assertEquals("first", bean.getName());
assertEquals("first", bean1.getName());
@@ -20,7 +20,7 @@ public class TestQueryFindReadOnly extends BaseTestCase {
Ebean.save(a0);
Article ar1 = Ebean.find(Article.class).setReadOnly(true).setId(a0.getId()).findUnique();
Article ar1 = Ebean.find(Article.class).setReadOnly(true).setId(a0.getId()).findOne();
Assert.assertNotNull(ar1);
Assert.assertTrue("readonly", Ebean.getBeanState(ar1).isReadOnly());
@@ -59,7 +59,7 @@ public class TestAutoTuneProfiling extends BaseTestCase {
return Ebean.find(Order.class)
.select("status, orderDate, shipDate")
.setId(id)
.findUnique();
.findOne();
}
private void useOrderDate() {
@@ -67,7 +67,7 @@ public class TestMultipleEmbeddedLoading extends BaseTestCase {
EInvoice invoicePartial = Ebean.find(EInvoice.class)
.select("state, date")
.where().idEq(invoice.getId())
.findUnique();
.findOne();
// lazy load of embedded bean
EAddress billAddress = invoicePartial.getBillAddress();
@@ -23,7 +23,7 @@ public class TestFindWhereUsingEnumerated extends BaseTestCase {
MNonUpdPropEntity unique = Ebean.find(MNonUpdPropEntity.class).where()
.eq("nonEnum", MNonEnum.END)
.eq("name", "TheNonEnumIsEnd")
.findUnique();
.findOne();
assertThat(unique).isNotNull();
}
@@ -39,7 +39,7 @@ public class TestOrderReportTotal extends BaseTestCase {
Query<OrderAggregate> q3 = Ebean.createQuery(OrderAggregate.class).setRawSql(rawSql);
q3.where().eq("order_id", 1);
OrderAggregate orderAggregate = q3.findUnique();
OrderAggregate orderAggregate = q3.findOne();
assertNotNull(orderAggregate);
}
@@ -48,7 +48,7 @@ public class TestRefreshWithMany extends BaseTestCase {
Customer customer1 = Ebean.find(Customer.class)
.fetch("contacts")
.setId(customer.getId())
.findUnique();
.findOne();
int rcb1 = Ebean.createSqlUpdate("update o_customer set name = :name where id = :id")
@@ -23,7 +23,7 @@ public class TestSaveAssociation extends BaseTestCase {
Ebean.save(m0);
TSMaster m0Check = Ebean.find(TSMaster.class).fetch("details").where().idEq(m0.getId())
.findUnique();
.findOne();
Assert.assertEquals(2, m0Check.getDetails().size());
@@ -27,7 +27,7 @@ public class TestSaveSamePK extends BaseTestCase {
Ebean.save(tsDetail);
TSDetail fetchedDetail = Ebean.find(TSDetail.class).setId(10000).fetch("master").findUnique();
TSDetail fetchedDetail = Ebean.find(TSDetail.class).setId(10000).fetch("master").findOne();
Assert.assertNotNull(fetchedDetail);
}
@@ -123,7 +123,7 @@ public class TestInheritQuery extends BaseTestCase {
// no discriminator here
wh2 = Ebean.find(Warehouse.class)
.where().eq("id", wh.getId())
.findUnique();
.findOne();
Assert.assertNotNull(wh2);
// discriminator is used here, should be in join
@@ -135,7 +135,7 @@ public class TestInheritQuery extends BaseTestCase {
wh2 = Ebean.find(Warehouse.class)
.fetch("officeZone")
.where().eq("id", wh.getId())
.findUnique();
.findOne();
// key assertion #1 - fails due to left join with discriminator in WHERE
Assert.assertNotNull(wh2);
@@ -151,7 +151,7 @@ public class TestInheritQuery extends BaseTestCase {
// query with lazy load of abstract children
wh = Ebean.find(Warehouse.class)
.where().eq("id", wh.getId())
.findUnique();
.findOne();
Assert.assertNotNull(wh);
Assert.assertEquals(wh.getId(), wh2.getId());
Assert.assertEquals(0, wh.getShippingZones().size());
@@ -160,7 +160,7 @@ public class TestInheritQuery extends BaseTestCase {
wh = Ebean.find(Warehouse.class)
.fetch("shippingZones")
.where().eq("id", wh.getId())
.findUnique();
.findOne();
// key assertion #2 - fails due to left join with discriminator in WHERE
Assert.assertNotNull(wh);
Assert.assertEquals(wh.getId(), wh2.getId());
@@ -27,19 +27,19 @@ public class TestSoftDeleteBasic extends BaseTestCase {
SqlQuery sqlQuery = Ebean.createSqlQuery("select * from ebasic_soft_delete where id=?");
sqlQuery.setParameter(1, bean.getId());
SqlRow sqlRow = sqlQuery.findUnique();
SqlRow sqlRow = sqlQuery.findOne();
assertThat(sqlRow).isNotNull();
EBasicSoftDelete findNormal = Ebean.find(EBasicSoftDelete.class)
.setId(bean.getId())
.findUnique();
.findOne();
assertThat(findNormal).isNull();
EBasicSoftDelete findInclude = Ebean.find(EBasicSoftDelete.class)
.setId(bean.getId())
.setIncludeSoftDeletes()
.findUnique();
.findOne();
assertThat(findInclude).isNotNull();
}
@@ -110,7 +110,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
EBasicSoftDelete partial = Ebean.find(EBasicSoftDelete.class)
.select("id")
.setId(bean.getId())
.findUnique();
.findOne();
LoggedSqlCollector.start();
Ebean.delete(partial);
@@ -198,7 +198,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
.setId(bean.getId())
.where()
.setIncludeSoftDeletes()
.findUnique();
.findOne();
assertThat(fetchAllWithLazy.getChildren()).hasSize(3);
}
@@ -218,7 +218,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
.setId(bean.getId())
.fetch("children");
EBasicSoftDelete found = query.findUnique();
EBasicSoftDelete found = query.findOne();
String generatedSql = sqlOf(query);
@@ -38,8 +38,8 @@ public class TestSoftDeleteBook extends BaseTestCase {
Ebean.save(book2);
// check if everything is stored correctly in DB
book1 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book1").findUnique();
book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").findUnique();
book1 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book1").findOne();
book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").findOne();
assertThat(book1.getLendBys().size()).isEqualTo(2);
assertThat(book2.getLendBys().size()).isEqualTo(2);
@@ -50,8 +50,8 @@ public class TestSoftDeleteBook extends BaseTestCase {
Ebean.delete(user1);
// check if everything is still stored correctly in DB (softdeletes included)
book1 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book1").setIncludeSoftDeletes().findUnique();
book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").setIncludeSoftDeletes().findUnique();
book1 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book1").setIncludeSoftDeletes().findOne();
book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").setIncludeSoftDeletes().findOne();
assertThat(book1.getLendBys().size()).isEqualTo(2);
assertThat(book2.getLendBys().size()).isEqualTo(2);
@@ -60,8 +60,8 @@ public class TestSoftDeleteBook extends BaseTestCase {
// check without softdeletes included
book1 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book1").findUnique();
book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").findUnique();
book1 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book1").findOne();
book2 = Ebean.find(ESoftDelBook.class).where().eq("bookTitle", "book2").findOne();
assertThat(book1.getLendBys().size()).isEqualTo(2); // user2 & user3
assertThat(book2.getLendBys().size()).isEqualTo(1); // user1 (deleted) & user3
@@ -101,7 +101,7 @@ public class TestSoftDeleteBook extends BaseTestCase {
.setId(book1.getId())
.fetch("lendBys");
ESoftDelBook found = query.findUnique();
ESoftDelBook found = query.findOne();
assertThat(found).isNotNull();
}
@@ -18,7 +18,7 @@ public class TestSoftDeleteOptionalRelationship extends BaseTestCase {
ESoftDelMid bean = Ebean.find(ESoftDelMid.class)
.setId(mid1.getId())
.fetch("top")
.findUnique();
.findOne();
assertThat(bean).isNotNull();
assertThat(bean.getTop()).isNull();
@@ -45,7 +45,7 @@ public class TestDeleteFromPersistenceContext extends BaseTestCase {
Ebean.endTransaction();
}
EBasicVer bean6 = Ebean.find(EBasicVer.class).where().eq("id", bean.getId()).findUnique();
EBasicVer bean6 = Ebean.find(EBasicVer.class).where().eq("id", bean.getId()).findOne();
assertNull("Bean where id eq is not found " + bean6, bean6);
awaitL2Cache();
@@ -28,7 +28,7 @@ public class TestFileType extends BaseTestCase {
SomeFileBean bean1 = Ebean.find(SomeFileBean.class)
.select("name, file")
.setId(bean0.getId())
.findUnique();
.findOne();
assertEquals("afile", bean1.getName());
assertNull(bean1.getContent());
@@ -39,7 +39,7 @@ public class TestFileType extends BaseTestCase {
SomeFileBean bean2 = Ebean.find(SomeFileBean.class)
.select("name, file")
.setId(bean0.getId())
.findUnique();
.findOne();
assertEquals("afile", bean2.getName());
assertNotNull(bean2.getContent());
@@ -61,7 +61,7 @@ public class TestFileType extends BaseTestCase {
SomeFileBean bean1 = Ebean.find(SomeFileBean.class)
.select("name, file")
.setId(bean0.getId())
.findUnique();
.findOne();
assertEquals("afile", bean1.getName());
assertNotNull(bean1.getContent());
@@ -76,7 +76,7 @@ public class TestFileType extends BaseTestCase {
SomeFileBean bean2 = Ebean.find(SomeFileBean.class)
.select("name, file")
.setId(bean0.getId())
.findUnique();
.findOne();
assertEquals(file2.length(), bean2.getContent().length());
@@ -88,7 +88,7 @@ public class TestFileType extends BaseTestCase {
SomeFileBean bean3 = Ebean.find(SomeFileBean.class)
.select("name, file")
.setId(bean0.getId())
.findUnique();
.findOne();
assertNull(bean3.getContent());
@@ -29,7 +29,7 @@ public class TestFileTypeFetching extends BaseTestCase {
SomeFileBean bean1 = Ebean.find(SomeFileBean.class)
.setId(bean0.getId())
.findUnique();
.findOne();
BeanState beanState = Ebean.getBeanState(bean1);
Set<String> loadedProps = beanState.getLoadedProps();
@@ -50,7 +50,7 @@ public class TestFileTypeFetching extends BaseTestCase {
SomeFileBean bean2 = Ebean.find(SomeFileBean.class)
.select("file")
.setId(bean0.getId())
.findUnique();
.findOne();
assertEquals(file2.length(), bean2.getContent().length());
@@ -26,7 +26,7 @@ public class TestEmbeddedRefreshUpdate extends BaseTestCase {
Ebean.save(outer);
EEmbOuter loaded = Ebean.find(EEmbOuter.class).where().idEq(outer.getId()).findUnique();
EEmbOuter loaded = Ebean.find(EEmbOuter.class).where().idEq(outer.getId()).findOne();
// if commented Ebean saves correctly
Ebean.refresh(loaded);
@@ -21,10 +21,10 @@ public class TestPostgresTruncate extends BaseTestCase {
//
// server.beginTransaction();
// Integer oriC =
// Ebean.createSqlQuery("select count(*) as c from e_basic").findUnique().getInteger("c");
// Ebean.createSqlQuery("select count(*) as c from e_basic").findOne().getInteger("c");
// int rows = Ebean.createSqlUpdate("truncate e_basic cascade").execute();
// Integer currentC =
// Ebean.createSqlQuery("select count(*) as c from e_basic").findUnique().getInteger("c");
// Ebean.createSqlQuery("select count(*) as c from e_basic").findOne().getInteger("c");
// server.commitTransaction();
// //Ebean.getServerCacheManager().clearAll();
// System.out.println("table : ori="+oriC+", delC="+rows+", currentC="+currentC);
@@ -26,7 +26,7 @@ public class TestUpdatePartial extends BaseTestCase {
.setUseCache(false)
.select("status, smallnote")
.setId(c.getId())
.findUnique();
.findOne();
c2.setStatus(Customer.Status.INACTIVE);
c2.setSmallnote("2nd note");
@@ -38,7 +38,7 @@ public class TestUpdatePartial extends BaseTestCase {
.setUseCache(false)
.select("status")
.setId(c.getId())
.findUnique();
.findOne();
c3.setStatus(Customer.Status.NEW);
c3.setSmallnote("3rd note");
@@ -50,7 +50,7 @@ public class TestUpdatePartial extends BaseTestCase {
private void checkDbStatusValue(Integer custId, String dbStatus) {
SqlQuery sqlQuery = Ebean.createSqlQuery("select id, status from o_customer where id = ?");
sqlQuery.setParameter(1, custId);
SqlRow sqlRow = sqlQuery.findUnique();
SqlRow sqlRow = sqlQuery.findOne();
String status = sqlRow.getString("status");
assertEquals(dbStatus, status);
}
@@ -18,7 +18,7 @@ public class TestUpdatePartialNoVer extends BaseTestCase {
Ebean.save(b);
EBasic basic = Ebean.find(EBasic.class).select("status, name").setId(b.getId()).findUnique();
EBasic basic = Ebean.find(EBasic.class).select("status, name").setId(b.getId()).findOne();
basic.setName("modiName");