* Equivalent to {@link Database#reference(Class, Object)}
*/
- @Nonnull
public T ref(I id) {
return db().reference(type, id);
}
@@ -97,7 +96,6 @@ public abstract class BeanFinder {
/**
* Find an entity by ID returning an Optional.
*/
- @Nullable
public Optional
-// * If you wish to execute a Sql Select natively then you should use the
-// * FindByNativeSql object.
-// *
-// * Note that the table modification information is automatically deduced and
-// * you do not need to call the DB.externalModification() method when you
-// * use this method.
-// *
-// * Example:
-// *
-// * Example:
-// *
diff --git a/ebean-api/src/main/java/io/ebean/Database.java b/ebean-api/src/main/java/io/ebean/Database.java
index 396f3225a..9c69e33fd 100644
--- a/ebean-api/src/main/java/io/ebean/Database.java
+++ b/ebean-api/src/main/java/io/ebean/Database.java
@@ -1,5 +1,7 @@
package io.ebean;
+import io.avaje.lang.NonNullApi;
+import io.avaje.lang.Nullable;
import io.ebean.annotation.Platform;
import io.ebean.annotation.TxIsolation;
import io.ebean.cache.ServerCacheManager;
@@ -10,8 +12,6 @@ import io.ebean.plugin.SpiServer;
import io.ebean.text.csv.CsvReader;
import io.ebean.text.json.JsonContext;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceException;
import javax.sql.DataSource;
@@ -92,6 +92,7 @@ import java.util.concurrent.Callable;
* @see DatabaseFactory
* @see DatabaseConfig
*/
+@NonNullApi
public interface Database {
/**
@@ -575,8 +576,8 @@ public interface Database {
* Refer to {@link DtoQuery} for native sql queries returning DTO beans.
@@ -949,7 +950,6 @@ public interface Database {
* @param beanType the type of entity bean
* @param id the id value
*/
- @Nonnull
+ * For Postgres this binds an ARRAY rather than expands into multiple bind values.
+ */
+ DtoQuery
* Note that the stream needs to be closed so use with try with resources.
*/
- @Nonnull
@Deprecated
@@ -62,6 +61,7 @@ import javax.annotation.Nonnull;
*
* @param
* Equivalent to {@link Database#reference(Class, Object)}
*/
- @Nonnull
public T ref(I id) {
return db().reference(type, id);
}
@@ -166,7 +166,6 @@ public class Finder {
/**
* Retrieves all entities of the given type.
*/
- @Nonnull
public List{@code
-// *
-// * // example that uses 'named' parameters
-// * String s = "UPDATE f_topic set post_count = :count where id = :id"
-// *
-// * SqlUpdate update = DB.createSqlUpdate(s);
-// *
-// * update.setParameter("id", 1);
-// * update.setParameter("count", 50);
-// *
-// * int modifiedCount = DB.execute(update);
-// *
-// * String msg = "There where " + modifiedCount + "rows updated";
-// *
-// * }
-// *
-// * @param sqlUpdate the update sql potentially with bind values
-// * @return the number of rows updated or deleted. -1 if executed in batch.
-// * @see SqlUpdate
-// * @see CallableSql
-// * @see DB#execute(CallableSql)
-// */
-// public static int execute(SqlUpdate sqlUpdate) {
-// return defaultDatabase().execute(sqlUpdate);
-// }
-//
-// /**
-// * For making calls to stored procedures.
-// * {@code
-// *
-// * String sql = "{call sp_order_modify(?,?,?)}";
-// *
-// * CallableSql cs = DB.createCallableSql(sql);
-// * cs.setParameter(1, 27);
-// * cs.setParameter(2, "SHIPPED");
-// * cs.registerOut(3, Types.INTEGER);
-// *
-// * DB.execute(cs);
-// *
-// * // read the out parameter
-// * Integer returnValue = (Integer) cs.getObject(3);
-// *
-// * }
-// *
-// * @see CallableSql
-// * @see Ebean#execute(SqlUpdate)
-// */
-// public static int execute(CallableSql callableSql) {
-// return defaultDatabase().execute(callableSql);
-// }
-
/**
* Execute a TxRunnable in a Transaction with an explicit scope.
*
@@ -324,6 +326,13 @@ public interface SqlUpdate { */ SqlUpdate setParameter(String name, Object param); + /** + * Bind the named multi-value array parameter which we would use with Postgres ANY. + *
+ * For Postgres this binds an ARRAY rather than expands into multiple bind values.
+ */
+ SqlUpdate setArrayParameter(String name, Collection> values);
+
/**
* Set a named parameter that has a null value. Exactly the same as
* {@link #setNullParameter(String, int)}.
diff --git a/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java b/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java
index 3725cc73c..28ac8a8e7 100644
--- a/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java
+++ b/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java
@@ -9,11 +9,7 @@ import javax.persistence.PersistenceException;
import java.io.Serializable;
import java.math.BigDecimal;
import java.net.URL;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -1164,7 +1160,7 @@ public final class EntityBeanIntercept implements Serializable {
*/
public Map
diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
index ba0ca78d1..281d0ea79 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
@@ -1547,6 +1547,9 @@ public class DatabaseConfig {
/**
* Set to true if all DB column and table names should use quoted identifiers.
+ *
+ * For Postgres pgjdbc version 42.3.0 should be used with datasource property
+ * quoteReturningIdentifiers set to false (refer #2303).
*/
public void setAllQuotedIdentifiers(boolean allQuotedIdentifiers) {
platformConfig.setAllQuotedIdentifiers(allQuotedIdentifiers);
diff --git a/ebean-api/src/main/java/io/ebean/config/PlatformConfig.java b/ebean-api/src/main/java/io/ebean/config/PlatformConfig.java
index 065af2393..bedbd7de5 100644
--- a/ebean-api/src/main/java/io/ebean/config/PlatformConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/PlatformConfig.java
@@ -120,6 +120,9 @@ public class PlatformConfig {
/**
* Set to true if all DB column and table names should use quoted identifiers.
+ *
+ * For Postgres pgjdbc version 42.3.0 should be used with datasource property
+ * quoteReturningIdentifiers set to false (refer #2303).
*/
public void setAllQuotedIdentifiers(boolean allQuotedIdentifiers) {
this.allQuotedIdentifiers = allQuotedIdentifiers;
diff --git a/ebean-api/src/main/java/io/ebean/plugin/BeanType.java b/ebean-api/src/main/java/io/ebean/plugin/BeanType.java
index 661b370d2..e7f324a56 100644
--- a/ebean-api/src/main/java/io/ebean/plugin/BeanType.java
+++ b/ebean-api/src/main/java/io/ebean/plugin/BeanType.java
@@ -8,7 +8,6 @@ import io.ebean.event.BeanPersistController;
import io.ebean.event.BeanPersistListener;
import io.ebean.event.BeanQueryAdapter;
-import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
@@ -21,7 +20,6 @@ public interface BeanType
@@ -285,12 +294,17 @@ public final class BindParams implements Serializable {
*/
public boolean isSameBindHash() {
if (bindHash == null) {
- bindHash = calcQueryPlanHash();
return false;
}
- String oldPlan = bindHash;
+ String newHash = calcQueryPlanHash();
+ return bindHash.equals(newHash);
+ }
+
+ /**
+ * Updates the hash.
+ */
+ public void updateHash() {
bindHash = calcQueryPlanHash();
- return bindHash.equals(oldPlan);
}
/**
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/LoadContext.java b/ebean-core/src/main/java/io/ebeaninternal/api/LoadContext.java
index 51f02826c..b23a183bb 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/LoadContext.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/LoadContext.java
@@ -36,14 +36,6 @@ public interface LoadContext {
*/
PersistenceContext getPersistenceContext();
- /**
- * Set the persistence context used by this query and future lazy loading.
- *
- * Used by query iterator when processing large result sets.
- *