diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index ce3ba3688..380438cc2 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 12.8.1-SNAPSHOT + 12.8.4-SNAPSHOT ebean api @@ -50,7 +50,7 @@ io.ebean ebean-annotation - 6.15 + 7.0 diff --git a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java index 6ad7b1d89..4aace866a 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseFactory.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseFactory.java @@ -78,7 +78,7 @@ public class DatabaseFactory { Database server = createInternal(config); if (config.isRegister()) { if (config.isDefaultServer()) { - if (defaultServerName != null) { + if (defaultServerName != null && !defaultServerName.equals(config.getName())) { throw new IllegalStateException("Registering [" + config.getName() + "] as the default server but [" + defaultServerName + "] is already registered as the default"); } defaultServerName = config.getName(); diff --git a/ebean-api/src/main/java/io/ebean/ExpressionList.java b/ebean-api/src/main/java/io/ebean/ExpressionList.java index 72f1c06f9..e91846e08 100644 --- a/ebean-api/src/main/java/io/ebean/ExpressionList.java +++ b/ebean-api/src/main/java/io/ebean/ExpressionList.java @@ -1671,7 +1671,7 @@ public interface ExpressionList { ExpressionList endAnd(); /** - * End a AND junction - synonym for endJunction(). + * End a OR junction - synonym for endJunction(). */ ExpressionList endOr(); diff --git a/ebean-api/src/main/java/io/ebean/FetchConfig.java b/ebean-api/src/main/java/io/ebean/FetchConfig.java index 64f4c3daa..e2d4fbe35 100644 --- a/ebean-api/src/main/java/io/ebean/FetchConfig.java +++ b/ebean-api/src/main/java/io/ebean/FetchConfig.java @@ -46,7 +46,7 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to one of the static factory methods like {@link FetchConfig#ofQuery()} - * + *

* Construct using default JOIN mode. */ @Deprecated @@ -89,7 +89,7 @@ public class FetchConfig implements Serializable { * Return FetchConfig to lazily load the relationship. */ public static FetchConfig ofLazy() { - return new FetchConfig(LAZY_MODE, 10); + return new FetchConfig(LAZY_MODE, 0); } /** @@ -110,8 +110,8 @@ public class FetchConfig implements Serializable { * We want to migrate away from mutating FetchConfig to a fully immutable FetchConfig. */ private FetchConfig mutate(int mode, int batchSize) { - if (batchSize < 1) { - throw new IllegalArgumentException("batch size "+batchSize+" must be > 0"); + if (batchSize < 0) { + throw new IllegalArgumentException("batch size " + batchSize + " must be > 0"); } this.mode = mode; this.batchSize = batchSize; @@ -124,7 +124,7 @@ public class FetchConfig implements Serializable { */ @Deprecated public FetchConfig lazy() { - return mutate(LAZY_MODE, 10); + return mutate(LAZY_MODE, 0); } /** @@ -137,7 +137,7 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to FetchConfig.ofQuery(). - * + *

* Eagerly fetch the beans in this path as a separate query (rather than as * part of the main query). *

@@ -150,17 +150,15 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to FetchConfig.ofQuery(batchSize). - * + *

* Eagerly fetch the beans in this path as a separate query (rather than as * part of the main query). *

* The queryBatchSize is the number of parent id's that this separate query * will load per batch. - *

*

* This will load all beans on this path eagerly unless a {@link #lazy(int)} * is also used. - *

* * @param batchSize the batch size used to load beans on this path */ @@ -171,13 +169,12 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to FetchConfig.ofQuery(batchSize). - * + *

* Eagerly fetch the first batch of beans on this path. * This is similar to {@link #query(int)} but only fetches the first batch. *

* If there are more parent beans than the batch size then they will not be * loaded eagerly but instead use lazy loading. - *

* * @param batchSize the number of parent beans this path is populated for */ @@ -188,7 +185,7 @@ public class FetchConfig implements Serializable { /** * Deprecated - migrate to FetchConfig.ofCache(). - * + *

* Eagerly fetch the beans fetching the beans from the L2 bean cache * and using the DB for beans not in the cache. */ diff --git a/ebean-api/src/main/java/io/ebean/Transaction.java b/ebean-api/src/main/java/io/ebean/Transaction.java index d4918e84e..0856a6e4e 100644 --- a/ebean-api/src/main/java/io/ebean/Transaction.java +++ b/ebean-api/src/main/java/io/ebean/Transaction.java @@ -59,6 +59,14 @@ public interface Transaction extends AutoCloseable { */ void register(TransactionCallback callback); + /** + * EXPERIMENTAL - turn on automatic persistence of dirty beans and batchMode true. + *

+ * With this turned on beans that are dirty in the persistence context + * are automatically persisted on flush() and commit(). + */ + void setAutoPersistUpdates(boolean autoPersistUpdates); + /** * Set a label on the transaction. *

@@ -339,15 +347,12 @@ public interface Transaction extends AutoCloseable { * The batch is automatically flushed when it hits the batch size and also when we * execute queries or when we mix UpdateSql and CallableSql with save and delete of * beans. - *

*

* We use {@link #flush()} to explicitly flush the batch and we can use * {@link #setFlushOnQuery(boolean)} and {@link #setFlushOnMixed(boolean)} * to control the automatic flushing behaviour. - *

*

* Example: batch processing of CallableSql executing every 10 rows - *

* *
{@code
    *
@@ -392,14 +397,11 @@ public interface Transaction extends AutoCloseable {
    * 

* This only takes effect when batch mode on the transaction has not already meant that * JDBC batch mode is being used. - *

*

* This is useful when the single save() or delete() cascades. For example, inserting a 'master' cascades * and inserts a collection of 'detail' beans. The detail beans can be inserted using JDBC batch. - *

*

* This is effectively already turned on for all platforms apart from older Sql Server. - *

* * @param batchMode the batch mode to use per save(), insert(), update() or delete() * @see io.ebean.config.DatabaseConfig#setPersistBatchOnCascade(PersistBatch) @@ -422,15 +424,19 @@ public interface Transaction extends AutoCloseable { int getBatchSize(); /** - * Specify if you want batched inserts to use getGeneratedKeys. + * Specify if we want batched inserts to use getGeneratedKeys. *

* By default batched inserts will try to use getGeneratedKeys if it is * supported by the underlying jdbc driver and database. - *

*

- * You may want to turn getGeneratedKeys off when you are inserting a large - * number of objects and you don't care about getting back the ids. - *

+ * We want to turn off getGeneratedKeys when we are inserting a large + * number of objects and we don't care about getting back the ids. In this + * way we avoid the extra cost of getting back the generated id values + * from the database. + *

+ * Note that when we do turn off getGeneratedKeys then we have the limitation + * that after a bean has been inserted we are unable to then mutate the bean + * and update it in the same transaction as we have not obtained it's id value. */ void setGetGeneratedKeys(boolean getGeneratedKeys); @@ -449,13 +455,11 @@ public interface Transaction extends AutoCloseable { *

* If you want to execute both WITHOUT having the batch automatically flush * you need to call this with batchFlushOnMixed = false. - *

*

* Note that UpdateSql and CallableSql are ALWAYS executed first (before the * beans are executed). This is because the UpdateSql and CallableSql have * already been bound to their PreparedStatements. The beans on the other hand * have a 2 step process (delayed binding). - *

*/ void setFlushOnMixed(boolean batchFlushOnMixed); @@ -473,7 +477,6 @@ public interface Transaction extends AutoCloseable { *

* Calling this method with batchFlushOnQuery = false means that you can * execute a query and the batch will not be automatically flushed. - *

*/ void setFlushOnQuery(boolean batchFlushOnQuery); @@ -490,7 +493,6 @@ public interface Transaction extends AutoCloseable { * should be flushed prior to executing a query. *

* The default is for this to be true. - *

*/ boolean isFlushOnQuery(); @@ -507,7 +509,6 @@ public interface Transaction extends AutoCloseable { * flush the batch if you like. *

* Flushing occurs automatically when: - *

*