diff --git a/ebean-api/src/main/java/io/ebean/ExtendedServer.java b/ebean-api/src/main/java/io/ebean/ExtendedServer.java index d6dc9af97..db8c6d9f5 100644 --- a/ebean-api/src/main/java/io/ebean/ExtendedServer.java +++ b/ebean-api/src/main/java/io/ebean/ExtendedServer.java @@ -2,7 +2,6 @@ package io.ebean; import io.avaje.lang.Nullable; -import javax.persistence.NonUniqueResultException; import java.time.Clock; import java.util.List; import java.util.Map; @@ -15,470 +14,182 @@ import java.util.stream.Stream; /** * The extended API for Database. *
+ * Deprecated in favour of using {@link Query#usingTransaction(Transaction)} instead. + *
* This provides the finder methods that take an explicit transaction rather than obtaining * the transaction from the usual mechanism (which is ThreadLocal based). - *
- *- * In general we only want to use this ExtendedServer API when we want to avoid / bypass - * the use of the mechanism to get the current transaction and instead explicitly supply - * the transaction to use. - *
** Note that in all cases the transaction supplied can be null and in this case the Database * will use the normal mechanism to obtain the transaction to use. - *
*/ public interface ExtendedServer { /** - * Return the NOW time from the Clock. - */ - long clockNow(); - - /** + * Deprecated but no yet determined suitable replacement (to support testing only change of clock). + *
* Set the Clock to use for @WhenCreated and @WhenModified.
*
* Note that we only expect to change the Clock for testing purposes. *
*/ + @Deprecated void setClock(Clock clock); /** - * Execute the query returning true if a row is found. - *- * The query is executed using max rows of 1 and will only select the id property. - * This method is really just a convenient way to optimise a query to perform a - * 'does a row exist in the db' check. - *
- * - *{@code
- *
- * boolean userExists = query().where().eq("email", "rob@foo.com").exists();
- *
- * }
- *
- * {@code
- *
- * boolean userExists = new QContact().email.equalTo("rob@foo.com").exists();
- *
- * }
- *
- * @return True if the query finds a matching row in the database
+ * Deprecated migrate to using {@link Query#usingTransaction(Transaction)}.
*/
+ @Deprecated
- * Generally using {@link #findEach(Query, Consumer, Transaction)} or - * {@link #findEachWhile(Query, Predicate, Transaction)} is preferred - * to findIterate(). The reason is that those methods automatically take care of - * closing the queryIterator (and the underlying jdbc statement and resultSet). - *
- * This is similar to findEach in that not all the result beans need to be held
- * in memory at the same time and as such is good for processing large queries.
- *
- * @see Query#findIterate()
- * @see Query#findEach(Consumer)
- * @see Query#findEachWhile(Predicate)
+ * Deprecated migrate to using {@link Query#usingTransaction(Transaction)}.
*/
+ @Deprecated
- * Note that this can support very large queries iterating any number of results.
- * To do so internally it can use multiple persistence contexts.
- *
- * Note that the stream needs to be closed so use with try with resources.
- *
- * Unlike findList() this is suitable for processing a query that will return
- * a very large resultSet. The reason is that not all the result beans need to be
- * held in memory at the same time and instead processed one at a time.
- *
- * Internally this query using a PersistenceContext scoped to each bean (and the
- * beans associated object graph).
- *
- *
- * Compared to findEach() this provides the ability to stop processing the query
- * results early by returning false for the Predicate.
- *
- * Unlike findList() this is suitable for processing a query that will return
- * a very large resultSet. The reason is that not all the result beans need to be
- * held in memory at the same time and instead processed one at a time.
- *
- * Internally this query using a PersistenceContext scoped to each bean (and the
- * beans associated object graph).
- *
- *
- * Generally this query is expected to be a find by id or unique predicates query.
- * It will execute the query against the history returning the versions of the bean.
- *
- * Generally you are able to use {@link Query#findList()} rather than
- * explicitly calling this method. You could use this method if you wish to
- * explicitly control the transaction used for the query.
- *
- *
- * This returns a Future object which can be used to cancel, check the
- * execution status (isDone etc) and get the value (with or without a
- * timeout).
- *
- * This returns a Future object which can be used to cancel, check the
- * execution status (isDone etc) and get the value (with or without a
- * timeout).
- *
- * This returns a Future object which can be used to cancel, check the
- * execution status (isDone etc) and get the value (with or without a timeout).
- *
- * This query will execute in it's own PersistenceContext and using its own transaction.
- * What that means is that it will not share any bean instances with other queries.
- *
- * @param query the query to execute in the background
- * @param transaction the transaction (can be null).
- * @return a Future object for the list result of the query
- * @see Query#findFutureList()
+ * Deprecated migrate to using {@link Query#usingTransaction(Transaction)}.
*/
+ @Deprecated
- * The benefit of using this over findList() is that it provides functionality to get the
- * total row count etc.
- *
- * If maxRows is not set on the query prior to calling findPagedList() then a
- * PersistenceException is thrown.
- *
- *
- * Generally you are able to use {@link Query#findSet()} rather than
- * explicitly calling this method. You could use this method if you wish to
- * explicitly control the transaction used for the query.
- *
- *
- * Generally you are able to use {@link Query#findMap()} rather than
- * explicitly calling this method. You could use this method if you wish to
- * explicitly control the transaction used for the query.
- *
- *
- * This will throw a NonUniqueResultException if the query finds more than one result.
- *
- * Generally you are able to use {@link Query#findOne()} rather than
- * explicitly calling this method. You could use this method if you wish to
- * explicitly control the transaction used for the query.
- *
- * Note that if the query includes joins then the generated delete statement may not be
- * optimal depending on the database platform.
- *
- * The update query must be created using {@link Database#update(Class)}.
- *
- * Generally you are able to use {@link SqlQuery#findList()} rather than
- * explicitly calling this method. You could use this method if you wish to
- * explicitly control the transaction used for the query.
- *
- * This streaming type query is useful for large query execution as only 1 row needs to be held in memory.
- *
- * Returning false after processing a row stops the iteration through the query results.
- *
- * This streaming type query is useful for large query execution as only 1 row needs to be held in memory.
- *
- * This will throw a PersistenceException if the query found more than one
- * result.
- *
- * Generally you are able to use {@link SqlQuery#findOne()} rather than
- * explicitly calling this method. You could use this method if you wish to
- * explicitly control the transaction used for the query.
- * P executeSqlQuery(Function{@code
- *
- * DB.find(Order.class)
- * .where().eq("status", Order.Status.NEW)
- * .order().asc("id")
- * .findEach((Order order) -> {
- *
- * // do something with the order bean
- * System.out.println(" -- processing order ... " + order);
- * });
- *
- * }
- *
- * @see Query#findEach(Consumer)
- * @see Query#findEachWhile(Predicate)
+ * Deprecated migrate to using {@link Query#usingTransaction(Transaction)}.
*/
+ @Deprecated
> consumer, Transaction t);
/**
- * Execute the query visiting the each bean one at a time.
- *
{@code
- *
- * DB.find(Order.class)
- * .where().eq("status", Order.Status.NEW)
- * .order().asc("id")
- * .findEachWhile((Order order) -> {
- *
- * // do something with the order bean
- * System.out.println(" -- processing order ... " + order);
- *
- * boolean carryOnProcessing = ...
- * return carryOnProcessing;
- * });
- *
- * }
- *
- * @see Query#findEach(Consumer)
- * @see Query#findEachWhile(Predicate)
+ * Deprecated migrate to using {@link Query#usingTransaction(Transaction)}.
*/
+ @Deprecated
{@code
- *
- * List
- *
- * @param {@code
- *
- * PagedList
- *
- * @return The PagedList
- * @see Query#findPagedList()
+ * Deprecated migrate to using {@link Query#usingTransaction(Transaction)}.
*/
+ @Deprecated
{@code
- *
- * Set
- *
- * @param Example 1:
- * {@code
- *
- * List
- * Example 2:
- * {@code
- *
- * List
- *
- * @return the list of values for the selected property
- * @see Query#findSingleAttributeList()
+ * Deprecated migrate to using {@link Query#usingTransaction(Transaction)}.
*/
+ @Deprecated
List findSingleAttributeList(Query