From aa1e0215010f11e4359f89e5c690313eb7bd2b13 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 7 Mar 2019 11:10:58 +1300 Subject: [PATCH] Javadoc update using "DB" --- src/main/java/io/ebean/Ebean.java | 10 +- src/main/java/io/ebean/ExtendedServer.java | 10 +- src/main/java/io/ebean/PagedList.java | 3 +- src/main/java/io/ebean/Query.java | 108 ++++++------------ src/main/java/io/ebean/Transaction.java | 6 +- src/main/java/io/ebean/UpdateQuery.java | 18 +-- .../java/io/ebean/config/ServerConfig.java | 2 +- 7 files changed, 52 insertions(+), 105 deletions(-) diff --git a/src/main/java/io/ebean/Ebean.java b/src/main/java/io/ebean/Ebean.java index c8cfc1304..2751cd3bf 100644 --- a/src/main/java/io/ebean/Ebean.java +++ b/src/main/java/io/ebean/Ebean.java @@ -631,7 +631,8 @@ public final class Ebean { * Customer customer = new Customer(); * customer.setId(7); * customer.setName("ModifiedNameNoOCC"); - * ebeanServer.update(customer); + * + * DB.update(customer); * * } * @@ -1131,10 +1132,9 @@ public final class Ebean { * * String sql = "select c.id, c.name from customer c where c.name like ? order by c.name"; * - * Query query = ebeanServer.findNative(Customer.class, sql); - * query.setParameter(1, "Rob%"); - * - * List customers = query.findList(); + * List customers = DB.findNative(Customer.class, sql) + * .setParameter(1, "Rob%") + * .findList() * * } * diff --git a/src/main/java/io/ebean/ExtendedServer.java b/src/main/java/io/ebean/ExtendedServer.java index 25e4c27ea..ce14e17d0 100644 --- a/src/main/java/io/ebean/ExtendedServer.java +++ b/src/main/java/io/ebean/ExtendedServer.java @@ -121,7 +121,7 @@ public interface ExtendedServer { *

*

{@code
    *
-   *     ebeanServer.find(Order.class)
+   *     DB.find(Order.class)
    *       .where().eq("status", Order.Status.NEW)
    *       .order().asc("id")
    *       .findEach((Order order) -> {
@@ -155,7 +155,7 @@ public interface ExtendedServer {
    * 

*

{@code
    *
-   *     ebeanServer.find(Order.class)
+   *     DB.find(Order.class)
    *       .where().eq("status", Order.Status.NEW)
    *       .order().asc("id")
    *       .findEachWhile((Order order) -> {
@@ -194,8 +194,7 @@ public interface ExtendedServer {
    * 

*

{@code
    *
-   * List customers =
-   *     ebeanServer.find(Customer.class)
+   * List customers = DB.find(Customer.class)
    *     .where().ilike("name", "rob%")
    *     .findList();
    *
@@ -301,8 +300,7 @@ public interface ExtendedServer {
    * 

*

{@code
    *
-   * Set customers =
-   *     ebeanServer.find(Customer.class)
+   * Set customers = DB.find(Customer.class)
    *     .where().ilike("name", "rob%")
    *     .findSet();
    *
diff --git a/src/main/java/io/ebean/PagedList.java b/src/main/java/io/ebean/PagedList.java
index 421fde776..6b0a92ef1 100644
--- a/src/main/java/io/ebean/PagedList.java
+++ b/src/main/java/io/ebean/PagedList.java
@@ -24,8 +24,7 @@ import java.util.concurrent.Future;
  *     // We want to find the first 50 new orders
  *     //  ... so we don't really need setFirstRow(0)
  *
- *     PagedList pagedList
- *       = ebeanServer.find(Order.class)
+ *     PagedList pagedList = DB.find(Order.class)
  *       .where().eq("status", Order.Status.NEW)
  *       .order().asc("id")
  *       .setFirstRow(0)
diff --git a/src/main/java/io/ebean/Query.java b/src/main/java/io/ebean/Query.java
index 308669fbf..712281e48 100644
--- a/src/main/java/io/ebean/Query.java
+++ b/src/main/java/io/ebean/Query.java
@@ -19,10 +19,7 @@ import java.util.function.Predicate;
  * 

*

{@code
  *
- * List orderList =
- *   ebeanServer.find(Order.class)
- *     .fetch("customer")
- *     .fetch("details")
+ * List orderList = DB.find(Order.class)
  *     .where()
  *       .like("customer.name","rob%")
  *       .gt("orderDate",lastWeek)
@@ -38,29 +35,14 @@ import java.util.function.Predicate;
  * 
{@code
  *
  * String oql =
- *   	+" fetch customer "
- *   	+" fetch details "
  *   	+" where customer.name like :custName and orderDate > :minOrderDate "
  *   	+" order by customer.id, id desc "
  *   	+" limit 50 ";
  *
- * Query query = ebeanServer.createQuery(Order.class, oql);
- * query.setParameter("custName", "Rob%");
- * query.setParameter("minOrderDate", lastWeek);
- *
- * List orderList = query.findList();
- * ...
- * }
- *

- * Example: Using a named query called "with.cust.and.details" - *

- *
{@code
- *
- * Query query = ebeanServer.createNamedQuery(Order.class,"with.cust.and.details");
- * query.setParameter("custName", "Rob%");
- * query.setParameter("minOrderDate", lastWeek);
- *
- * List orderList = query.findList();
+ * List orderList = DB.createQuery(Order.class, oql)
+ *   .setParameter("custName", "Rob%")
+ *   .setParameter("minOrderDate", lastWeek)
+ *   .findList();
  * ...
  * }
*

AutoTune

@@ -436,8 +418,7 @@ public interface Query { *

*
{@code
    *
-   * List customers =
-   *     ebeanServer.find(Customer.class)
+   * List customers = DB.find(Customer.class)
    *     // Only fetch the customer id, name and status.
    *     // This is described as a "Partial Object"
    *     .select("name, status")
@@ -465,8 +446,7 @@ public interface Query {
    * 
{@code
    *
    * // query orders...
-   * List orders =
-   *     ebeanServer.find(Order.class)
+   * List orders = DB.find(Order.class)
    *       // fetch the customer...
    *       // ... getting the customers name and phone number
    *       .fetch("customer", "name, phoneNumber")
@@ -481,8 +461,7 @@ public interface Query {
    * 
{@code
    *
    * // fetch customers (their id, name and status)
-   * List customers =
-   *     ebeanServer.find(Customer.class)
+   * List customers = DB.find(Customer.class)
    *     .select("name, status")
    *     .fetch("contacts", "firstName,lastName,email")
    *     .findList();
@@ -551,8 +530,7 @@ public interface Query {
    * 
{@code
    *
    * // fetch customers (their id, name and status)
-   * List customers =
-   *     ebeanServer.find(Customer.class)
+   * List customers = DB.find(Customer.class)
    *     .select("name, status")
    *     .fetch("contacts", "firstName,lastName,email", new FetchConfig().lazy(10))
    *     .findList();
@@ -573,8 +551,7 @@ public interface Query {
    * 
{@code
    *
    * // fetch customers (their id, name and status)
-   * List customers =
-   *     ebeanServer.find(Customer.class)
+   * List customers = DB.find(Customer.class)
    *     // eager fetch the contacts
    *     .fetch("contacts")
    *     .findList();
@@ -637,8 +614,7 @@ public interface Query {
    * 
{@code
    *
    * // fetch customers (their id, name and status)
-   * List customers =
-   *     ebeanServer.find(Customer.class)
+   * List customers = DB.find(Customer.class)
    *     // lazy fetch contacts with a batch size of 100
    *     .fetch("contacts", new FetchConfig().lazy(100))
    *     .findList();
@@ -684,8 +660,7 @@ public interface Query {
    * 

*
{@code
    *
-   *  Query query =
-   *    ebeanServer.find(Customer.class)
+   *  Query query = DB.find(Customer.class)
    *     .where().eq("status", Status.NEW)
    *     .order().asc("id");
    *
@@ -732,7 +707,7 @@ public interface Query {
    * 

*
{@code
    *
-   *  ebeanServer.find(Customer.class)
+   *  DB.find(Customer.class)
    *     .where().eq("status", Status.NEW)
    *     .order().asc("id")
    *     .findEach((Customer customer) -> {
@@ -761,7 +736,7 @@ public interface Query {
    * 

*
{@code
    *
-   *  ebeanServer.find(Customer.class)
+   *  DB.find(Customer.class)
    *     .fetch("contacts", new FetchConfig().query(2))
    *     .where().eq("status", Status.NEW)
    *     .order().asc("id")
@@ -788,8 +763,7 @@ public interface Query {
    * 

*
{@code
    *
-   * List customers =
-   *     ebeanServer.find(Customer.class)
+   * List customers = DB.find(Customer.class)
    *     .where().ilike("name", "rob%")
    *     .findList();
    *
@@ -805,8 +779,7 @@ public interface Query {
    * 

*
{@code
    *
-   * Set customers =
-   *     ebeanServer.find(Customer.class)
+   * Set customers = DB.find(Customer.class)
    *     .where().ilike("name", "rob%")
    *     .findSet();
    *
@@ -826,8 +799,7 @@ public interface Query {
    * 

*
{@code
    *
-   * Map map =
-   *   ebeanServer.find(Product.class)
+   * Map map = DB.find(Product.class)
    *     .setMapKey("sku")
    *     .findMap();
    *
@@ -934,8 +906,7 @@ public interface Query {
    * 
{@code
    *
    * // assuming the sku of products is unique...
-   * Product product =
-   *     ebeanServer.find(Product.class)
+   * Product product = DB.find(Product.class)
    *         .where().eq("sku", "aa113")
    *         .findOne();
    * ...
@@ -947,8 +918,7 @@ public interface Query {
    * 
{@code
    *
    * // Fetch order 1 and additionally fetch join its order details...
-   * Order order =
-   *     ebeanServer.find(Order.class)
+   * Order order = DB.find(Order.class)
    *       .setId(1)
    *       .fetch("details")
    *       .findOne();
@@ -1114,11 +1084,9 @@ public interface Query {
    * // a query with a named parameter
    * String oql = "find order where status = :orderStatus";
    *
-   * Query query = ebeanServer.find(Order.class, oql);
-   *
-   * // bind the named parameter
-   * query.bind("orderStatus", OrderStatus.NEW);
-   * List list = query.findList();
+   * List list = DB.find(Order.class, oql)
+   *   .setParameter("orderStatus", OrderStatus.NEW)
+   *   .findList();
    *
    * }
* @@ -1136,12 +1104,9 @@ public interface Query { * // a query with a positioned parameter * String oql = "where status = ? order by id desc"; * - * Query query = ebeanServer.createQuery(Order.class, oql); - * - * // bind the parameter - * query.setParameter(1, OrderStatus.NEW); - * - * List list = query.findList(); + * List list = DB.createQuery(Order.class, oql) + * .setParameter(1, OrderStatus.NEW) + * .findList(); * * }
* @@ -1158,8 +1123,7 @@ public interface Query { *

*
{@code
    *
-   * Order order =
-   *     ebeanServer.find(Order.class)
+   * Order order = DB.find(Order.class)
    *     .setId(1)
    *     .fetch("details")
    *     .findOne();
@@ -1180,8 +1144,7 @@ public interface Query {
    * Add a single Expression to the where clause returning the query.
    * 
{@code
    *
-   * List newOrders =
-   *     ebeanServer.find(Order.class)
+   * List newOrders = DB.find(Order.class)
    * 		.where().eq("status", Order.NEW)
    * 		.findList();
    * ...
@@ -1196,8 +1159,7 @@ public interface Query {
    * where clause.
    * 
{@code
    *
-   * List orders =
-   *     ebeanServer.find(Order.class)
+   * List orders = DB.find(Order.class)
    *     .where()
    *       .eq("status", Order.NEW)
    *       .ilike("customer.name","rob%")
@@ -1243,10 +1205,7 @@ public interface Query {
    * 

*
{@code
    *
-   * List list =
-   *     ebeanServer.find(Customer.class)
-   *     // .fetch("orders", new FetchConfig().lazy())
-   *     // .fetch("orders", new FetchConfig().query())
+   * List list = DB.find(Customer.class)
    *     .fetch("orders")
    *     .where().ilike("name", "rob%")
    *     .filterMany("orders").eq("status", Order.Status.NEW).gt("orderDate", lastWeek)
@@ -1260,8 +1219,7 @@ public interface Query {
    * 

* * @param propertyName the name of the many property that you want to have a filter on. - * @return the expression list that you add filter expressions for the many - * to. + * @return the expression list that you add filter expressions for the many to. */ ExpressionList filterMany(String propertyName); @@ -1447,10 +1405,8 @@ public interface Query { * * // Assuming sku is unique for products... * - * Map productMap = - * ebeanServer.find(Product.class) - * // use sku for keys... - * .setMapKey("sku") + * Map productMap = DB.find(Product.class) + * .setMapKey("sku") // sku map keys... * .findMap(); * * }
diff --git a/src/main/java/io/ebean/Transaction.java b/src/main/java/io/ebean/Transaction.java index 465df6732..4ec8e2701 100644 --- a/src/main/java/io/ebean/Transaction.java +++ b/src/main/java/io/ebean/Transaction.java @@ -244,7 +244,7 @@ public interface Transaction extends AutoCloseable { * * // assume Customer has L2 bean caching enabled ... * - * try (Transaction transaction = ebeanServer.beginTransaction()) { + * try (Transaction transaction = DB.beginTransaction()) { * * // this uses L2 bean cache as the transaction * // ... is considered "query only" at this point @@ -366,13 +366,13 @@ public interface Transaction extends AutoCloseable { * // inserts into a table called sp_test * cs.addModification("sp_test", true, false, false); * - * try (Transaction txn = ebeanServer.beginTransaction()) { + * try (Transaction txn = DB.beginTransaction()) { * txn.setBatchMode(true); * txn.setBatchSize(10); * * for (int i = 0; i < da.length;) { * cs.setParameter(1, da[i]); - * ebeanServer.execute(cs); + * DB.execute(cs); * } * * // Note: commit implicitly flushes diff --git a/src/main/java/io/ebean/UpdateQuery.java b/src/main/java/io/ebean/UpdateQuery.java index 336ad38b1..1860fffe9 100644 --- a/src/main/java/io/ebean/UpdateQuery.java +++ b/src/main/java/io/ebean/UpdateQuery.java @@ -12,8 +12,7 @@ package io.ebean; *

*

{@code
  *
- *  int rows = ebeanServer
- *      .update(Customer.class)
+ *  int rows = DB.update(Customer.class)
  *      .set("status", Customer.Status.ACTIVE)
  *      .set("updtime", new Timestamp(System.currentTimeMillis()))
  *      .where()
@@ -39,8 +38,7 @@ package io.ebean;
  * 

*

{@code
  *
- *   int rows = ebeanServer
- *       .update(Customer.class)
+ *   int rows = DB.update(Customer.class)
  *       .set("status", Customer.Status.ACTIVE)
  *       .set("updtime", new Timestamp(System.currentTimeMillis()))
  *       .where()
@@ -73,8 +71,7 @@ public interface UpdateQuery {
    * 

*

{@code
    *
-   *   int rows = ebeanServer
-   *      .update(Customer.class)
+   *   int rows = DB.update(Customer.class)
    *      .set("status", Customer.Status.ACTIVE)
    *      .set("updtime", new Timestamp(System.currentTimeMillis()))
    *      .where()
@@ -93,8 +90,7 @@ public interface UpdateQuery {
    * 

*

{@code
    *
-   *   int rows = ebeanServer
-   *      .update(Customer.class)
+   *   int rows = DB.update(Customer.class)
    *      .setNull("notes")
    *      .where()
    *      .gt("id", 1000)
@@ -114,8 +110,7 @@ public interface UpdateQuery {
    * 

*

{@code
    *
-   *   int rows = ebeanServer
-   *      .update(Customer.class)
+   *   int rows = DB.update(Customer.class)
    *      .setRaw("status = coalesce(status, 'A')")
    *      .where()
    *      .gt("id", 1000)
@@ -134,8 +129,7 @@ public interface UpdateQuery {
    * 

*
{@code
    *
-   *   int rows = ebeanServer
-   *      .update(Customer.class)
+   *   int rows = DB.update(Customer.class)
    *      .setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE)
    *      .where()
    *      .gt("id", 1000)
diff --git a/src/main/java/io/ebean/config/ServerConfig.java b/src/main/java/io/ebean/config/ServerConfig.java
index 27c1098d7..e57e4fd45 100644
--- a/src/main/java/io/ebean/config/ServerConfig.java
+++ b/src/main/java/io/ebean/config/ServerConfig.java
@@ -2422,7 +2422,7 @@ public class ServerConfig {
   }
 
   /**
-   * Return true if the ebeanServer should collection query statistics by ObjectGraphNode.
+   * Return true if query statistics should be collected by ObjectGraphNode.
    */
   public boolean isCollectQueryStatsByNode() {
     return collectQueryStatsByNode;