Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced .order() with .orderBy() #3508

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ebean-api/src/main/java/io/ebean/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public static <T> T reference(Class<T> beanType, Object id) {
* // find orders and their customers
* List<Order> list = DB.find(Order.class)
* .fetch("customer")
* .order("id")
* .orderBy("id")
* .findList();
*
* // sort by customer name ascending, then by order shipDate
Expand Down
2 changes: 1 addition & 1 deletion ebean-api/src/main/java/io/ebean/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ static DatabaseBuilder builder() {
* // find orders and their customers
* List<Order> list = database.find(Order.class)
* .fetch("customer")
* .order("id")
* .orderBy("id")
* .findList();
*
* // sort by customer name ascending, then by order shipDate
Expand Down
12 changes: 6 additions & 6 deletions ebean-api/src/main/java/io/ebean/ExpressionList.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ default OrderBy<T> order() {
* List<String> names =
* DB.find(Customer.class)
* .select("name")
* .order().asc("name")
* .orderBy().asc("name")
* .findSingleAttributeList();
*
* }</pre>
Expand All @@ -368,7 +368,7 @@ default OrderBy<T> order() {
* .setDistinct(true)
* .select("name")
* .where().eq("status", Customer.Status.NEW)
* .order().asc("name")
* .orderBy().asc("name")
* .setMaxRows(100)
* .findSingleAttributeList();
*
Expand Down Expand Up @@ -1713,7 +1713,7 @@ default ExpressionList<T> isIn(String propertyName, Collection<?> values) {
* .eq("status", Customer.Status.ACTIVE)
* .gt("id", 0)
* .endAnd()
* .order().asc("name")
* .orderBy().asc("name")
* .findList();
* }</pre>
*/
Expand All @@ -1734,7 +1734,7 @@ default ExpressionList<T> isIn(String propertyName, Collection<?> values) {
* .or()
* .eq("status", Customer.Status.ACTIVE)
* .isNull("anniversary")
* .order().asc("name")
* .orderBy().asc("name")
* .findList();
*
* }</pre>
Expand All @@ -1754,7 +1754,7 @@ default ExpressionList<T> isIn(String propertyName, Collection<?> values) {
* .eq("status", Customer.Status.ACTIVE)
* .gt("id", 0)
* .endAnd()
* .order().asc("name")
* .orderBy().asc("name")
* .findList();
*
* }</pre>
Expand Down Expand Up @@ -1788,7 +1788,7 @@ default ExpressionList<T> isIn(String propertyName, Collection<?> values) {
* .gt("id", 1)
* .eq("anniversary", onAfter)
* .endNot()
* .order()
* .orderBy()
* .asc("name")
* .findList();
*
Expand Down
2 changes: 1 addition & 1 deletion ebean-api/src/main/java/io/ebean/Finder.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* public List<Customer> findNew() {
* return query().where()
* .eq("status", Customer.Status.NEW)
* .order("name")
* .orderBy("name")
* .findList()
* }
* }
Expand Down
2 changes: 1 addition & 1 deletion ebean-api/src/main/java/io/ebean/Junction.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* .eq("status", Customer.Status.ACTIVE)
* .gt("id", 0)
* .endAnd()
* .order().asc("name");
* .orderBy().asc("name");
*
* q.findList();
* String s = q.getGeneratedSql();
Expand Down
2 changes: 1 addition & 1 deletion ebean-api/src/main/java/io/ebean/PagedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* PagedList<Order> pagedList = DB.find(Order.class)
* .where().eq("status", Order.Status.NEW)
* .order().asc("id")
* .orderBy().asc("id")
* .setFirstRow(0)
* .setMaxRows(50)
* .findPagedList();
Expand Down
2 changes: 1 addition & 1 deletion ebean-api/src/main/java/io/ebean/Pairs.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* .where()
* .eq("store", "def")
* .inPairs(pairs) // IN clause with 'pairs' of values
* .order("sku desc")
* .orderBy("sku desc")
*
* // query expressions cover the natural key properties
* // so we can choose to hit the L2 bean cache if we want
Expand Down
2 changes: 1 addition & 1 deletion ebean-api/src/main/java/io/ebean/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* .where()
* .like("customer.name","rob%")
* .gt("orderDate",lastWeek)
* .order("customer.id, id desc")
* .orderBy("customer.id, id desc")
* .setMaxRows(50)
* .findList();
*
Expand Down
2 changes: 1 addition & 1 deletion ebean-api/src/main/java/io/ebean/QueryIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* Query<Customer> query = database.find(Customer.class)
* .where().gt("id", 0)
* .order("id")
* .orderBy("id")
* .setMaxRows(2);
*
* QueryIterator<Customer> it = query.findIterate();
Expand Down
2 changes: 1 addition & 1 deletion ebean-api/src/main/java/io/ebean/RawSql.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
* .fetch("order.customer", "name")
* .where().gt("order.id", 0)
* .having().gt("totalAmount", 20)
* .order().desc("totalAmount")
* .orderBy().desc("totalAmount")
* .setMaxRows(10)
* .findList();
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* .fetch("billingAddress","line1, city")
* .fetch("billingAddress.country", "*")
* .fetch("contacts", "firstName,email")
* .order().desc("id")
* .orderBy().desc("id")
* .findList();
*
* JsonContext json = DB.json();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3186,8 +3186,8 @@ public void diff(String prefix, Map<String, ValuePair> map, EntityBean newBean,
* provides unique ordering of the rows (so that the paging is predicable).
*/
public void appendOrderById(SpiQuery<T> query) {
if (idProperty != null && !idProperty.isEmbedded() && !query.order().containsProperty(idProperty.name())) {
query.order().asc(idProperty.name());
if (idProperty != null && !idProperty.isEmbedded() && !query.orderBy().containsProperty(idProperty.name())) {
query.orderBy().asc(idProperty.name());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void applyRowLimits(SpiQuery<?> query) {
query.setMaxRows(maxRows);
}
if (orderByClause != null) {
query.order(orderByClause);
query.orderBy(orderByClause);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void enterOrderby_property(EQLParser.Orderby_propertyContext ctx) {
}
}

query.order().add(new OrderBy.Property(path, asc, nulls, nullsFirstLast));
query.orderBy().add(new OrderBy.Property(path, asc, nulls, nullsFirstLast));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public <T> List<Version<T>> findVersions(OrmQueryRequest<T> request) {
}

// order by lower sys period desc
query.order().desc(sysPeriodLower);
query.orderBy().desc(sysPeriodLower);
CQuery<T> cquery = queryBuilder.buildQuery(request);
request.setCancelableQuery(cquery);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,20 @@ public void equals_when_diffDisableLazyLoading() {
@Test
public void equals_when_diffOrderByNull() {

CQueryPlanKey key1 = planKey(query().order("id"));
CQueryPlanKey key1 = planKey(query().orderBy("id"));
CQueryPlanKey key2 = planKey(query());
assertDifferent(key1, key2);

key1 = planKey(query().order().asc("id"));
key1 = planKey(query().orderBy().asc("id"));
key2 = planKey(query());
assertDifferent(key1, key2);
}

@Test
public void equals_when_orderBySame() {

CQueryPlanKey key1 = planKey(query().order("id, name"));
CQueryPlanKey key2 = planKey(query().order("id, name"));
CQueryPlanKey key1 = planKey(query().orderBy("id, name"));
CQueryPlanKey key2 = planKey(query().orderBy("id, name"));
assertSame(key1, key2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public TQPropertyBase(String name, R root, String prefix) {
* Order by ascending on this property.
*/
public final R asc() {
expr().order().asc(_name);
expr().orderBy().asc(_name);
return _root;
}

/**
* Order by descending on this property.
*/
public final R desc() {
expr().order().desc(_name);
expr().orderBy().desc(_name);
return _root;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testPlanHits() {
DB.find(Contact.class)
.setProfileLocation(loc0)
.select("email, " + concat("lastName", ", ", "firstName") + " as fullName").where()
.istartsWith(concat("lastName", ", ", "firstName"), val).order().asc("lastName").setMaxRows(10)
.istartsWith(concat("lastName", ", ", "firstName"), val).orderBy().asc("lastName").setMaxRows(10)
.asDto(ContactDto.class).setLabel("prefixLoop").findList();
}

Expand Down Expand Up @@ -196,7 +196,7 @@ public void asDto_withoutSelectClause() {
LoggedSql.start();

DtoQuery<ContactDto2> query = DB.find(Contact.class)
.where().isNotNull("email").order().asc("lastName")
.where().isNotNull("email").orderBy().asc("lastName")
.asDto(ContactDto2.class)
.setRelaxedMode();

Expand Down Expand Up @@ -226,7 +226,7 @@ public void asDto_withoutExplicitId() {
.where()
.isNotNull("email")
.isNotNull("lastName")
.order().asc("lastName")
.orderBy().asc("lastName")
.asDto(ContactDto.class);

List<ContactDto> dtos = query.findList();
Expand Down Expand Up @@ -288,7 +288,7 @@ public void example_explicitId() {

List<ContactDto> contactDtos = DB.find(Contact.class)
.select("id, email, " + concat("lastName", ", ", "firstName") + " as fullName").where().isNotNull("email")
.isNotNull("lastName").order().asc("lastName").setMaxRows(10).asDto(ContactDto.class).findList();
.isNotNull("lastName").orderBy().asc("lastName").setMaxRows(10).asDto(ContactDto.class).findList();

assertThat(contactDtos).isNotEmpty();

Expand Down Expand Up @@ -317,7 +317,7 @@ public void example_singleProperty() {
LoggedSql.start();

List<ContactDto> contactDtos = DB.find(Contact.class)
.select(concat("lastName", ", ", "firstName") + " as fullName").where().isNotNull("lastName").order()
.select(concat("lastName", ", ", "firstName") + " as fullName").where().isNotNull("lastName").orderBy()
.asc("lastName").asDto(ContactDto.class).setFirstRow(2).setMaxRows(5).findList();

assertThat(contactDtos).isNotEmpty();
Expand All @@ -340,7 +340,7 @@ public void example_aggregate() {
LoggedSql.start();

List<ContactTotals> contactDtos = DB.find(Contact.class).select("lastName, count(*) as totalCount").where()
.isNotNull("lastName").having().gt("count(*)", 1).order().desc("count(*)").asDto(ContactTotals.class)
.isNotNull("lastName").having().gt("count(*)", 1).orderBy().desc("count(*)").asDto(ContactTotals.class)
.findList();

assertThat(contactDtos).isNotEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void basic_limit_offset3() {
query.setMaxRows(10);
query.setFirstRow(3);
if (isSqlServer()) {
query.order("id");
query.orderBy("id");
}
query.findList();

Expand Down Expand Up @@ -213,7 +213,7 @@ public void namedQuery_withStatus() {
ResetBasicData.reset();

Query<Customer> name = server().createNamedQuery(Customer.class, "withStatus");
name.order().clear().asc("status");
name.orderBy().clear().asc("status");
name.findList();

assertThat(sqlOf(name, 2)).contains("select t0.id, t0.name, t0.status from o_customer t0 order by t0.status");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void test() {
.fetch("billingAddress", "line1, city")
.fetch("billingAddress.country", "*")
.fetch("contacts", "firstName,email")
.order().desc("id")
.orderBy().desc("id")
.findList();

JsonContext json = DB.json();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void test() {
.fetch("billingAddress", "line1, city")
.fetch("billingAddress.country", "*")
.fetch("contacts", "firstName,email")
.order().desc("id")
.orderBy().desc("id")
.findList();

JsonContext json = DB.json();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void minDistinctOrderByNulls() {
List<Contact> contacts = DB.find(Contact.class)
.setDistinct(true)
.select("lastName, min(customer)")
.order("min(customer) asc nulls last")
.orderBy("min(customer) asc nulls last")
.findList();

List<String> sql = LoggedSql.stop();
Expand Down
4 changes: 2 additions & 2 deletions ebean-test/src/test/java/org/tests/basic/MainDbBoolean.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private void simpleCheck(Database server) {

List<TOne> list = server.find(TOne.class)
.setAutoTune(false)
.order("id")
.orderBy("id")
.findList();

assertThat(list).hasSize(2);
Expand All @@ -135,7 +135,7 @@ private void simpleCheck(Database server) {

Query<TOne> query = server.find(TOne.class)
.setAutoTune(false)
.order("id");
.orderBy("id");

int rc = query.findCount();
assertThat(rc).isGreaterThan(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void testLoadInCache() {
.select("id, name")
.setBeanCacheMode(CacheMode.PUT)
.setReadOnly(true)
.order().asc("id")
.orderBy().asc("id")
.findMap();

assertFalse(map.isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testMaxRowsZeroWithFirstRow() {
.where().gt("details.id", 0)
.setMaxRows(0)
.setFirstRow(3)
.order().asc("orderDate");
.orderBy().asc("orderDate");

query.findList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void testLoad() {
.setBeanCacheMode(CacheMode.PUT)
.setUseQueryCache(true)
.setReadOnly(true)
.order("name")
.orderBy("name")
.findMap();

Country loadedNz = map.get("NZ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testLazyLoadRef() throws InterruptedException {

awaitL2Cache();

List<Order> list = DB.find(Order.class).order().asc("id").findList();
List<Order> list = DB.find(Order.class).orderBy().asc("id").findList();
assertFalse(list.isEmpty());

// just use the first one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void testCountOrderBy() {
Timestamp t = new Timestamp(System.currentTimeMillis());

Query<Order> query = DB.find(Order.class).setAutoTune(false).where()
.betweenProperties("cretime", "updtime", t).order().asc("orderDate").order().desc("id");
.betweenProperties("cretime", "updtime", t).orderBy().asc("orderDate").orderBy().desc("id");

query.findList();

Expand Down Expand Up @@ -91,8 +91,8 @@ private void someQuery() {
Query<Order> query = DB.find(Order.class).setAutoTune(false)
.where()
.le("cretime", t)
.order().asc("orderDate")
.order().desc("id");
.orderBy().asc("orderDate")
.orderBy().desc("id");

query.findList();

Expand Down
Loading