From ef1143bb702822654d40b4e05312e4ada477c7a0 Mon Sep 17 00:00:00 2001
From: Roland Praml
Date: Tue, 2 Mar 2021 15:26:29 +0100
Subject: [PATCH 001/111] FIX: orderBy does not work when used on formula
property or in conjunction with "exists" query
---
.../server/query/CQueryBuilder.java | 12 +++++--
.../server/querydefn/DefaultOrmQuery.java | 9 +++++
.../java/org/tests/basic/TestFetchId.java | 36 +++++++++++++++++++
3 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java
index ab008a5cf..1162e914d 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBuilder.java
@@ -616,11 +616,19 @@ class CQueryBuilder {
if (request.isInlineCountDistinct()) {
sb.append(")");
}
- if (distinct && dbOrderBy != null && !query.isSingleAttribute()) {
+ if (distinct && dbOrderBy != null) {
// add the orderBy columns to the select clause (due to distinct)
final OrderBy> orderBy = query.getOrderBy();
if (orderBy != null && orderBy.supportsSelect()) {
- sb.append(", ").append(DbOrderByTrim.trim(dbOrderBy));
+ String trimmed = DbOrderByTrim.trim(dbOrderBy);
+ if (query.isSingleAttribute() && trimmed.equals(select.getSelectSql())) {
+ // NOP, already in SQL
+ // TODO: what to do if we select("id").orderBy("prop,id")?
+ // Can we live with a query like "select t0.id, t0.prop, t0.id from"
+ // or should we elliminate the second "t0.id" from select
+ } else {
+ sb.append(", ").append(trimmed);
+ }
}
}
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
index 6f72febb9..e6eafc0b8 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
@@ -53,6 +53,7 @@ import io.ebeaninternal.server.deploy.BeanNaturalKey;
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
import io.ebeaninternal.server.deploy.InheritInfo;
import io.ebeaninternal.server.deploy.TableJoin;
+import io.ebeaninternal.server.el.ElPropertyDeploy;
import io.ebeaninternal.server.expression.DefaultExpressionList;
import io.ebeaninternal.server.expression.IdInExpression;
import io.ebeaninternal.server.expression.SimpleExpression;
@@ -537,6 +538,14 @@ public class DefaultOrmQuery implements SpiQuery {
if (havingExpressions != null) {
havingExpressions.containsMany(beanDescriptor, manyWhereJoins);
}
+ if (orderBy != null) {
+ for (Property orderProperty : orderBy.getProperties()) {
+ ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(orderProperty.getProperty());
+ if (elProp != null && elProp.containsFormulaWithJoin()) {
+ manyWhereJoins.addFormulaWithJoin(orderProperty.getProperty());
+ }
+ }
+ }
}
/**
diff --git a/ebean-core/src/test/java/org/tests/basic/TestFetchId.java b/ebean-core/src/test/java/org/tests/basic/TestFetchId.java
index cf207995c..c830208d5 100644
--- a/ebean-core/src/test/java/org/tests/basic/TestFetchId.java
+++ b/ebean-core/src/test/java/org/tests/basic/TestFetchId.java
@@ -1,10 +1,14 @@
package org.tests.basic;
import io.ebean.BaseTestCase;
+import io.ebean.DB;
import io.ebean.Ebean;
import io.ebean.FutureIds;
import io.ebean.Query;
+import io.ebeantest.LoggedSql;
+
import org.tests.model.basic.Order;
+import org.tests.model.basic.OrderDetail;
import org.tests.model.basic.ResetBasicData;
import org.junit.Test;
@@ -36,4 +40,36 @@ public class TestFetchId extends BaseTestCase {
List idList = futureIds.get();
assertThat(idList).isNotEmpty();
}
+
+ @Test
+ public void testFetchIdWithExists() throws InterruptedException, ExecutionException {
+
+ ResetBasicData.reset();
+
+ Query subQuery = Ebean.find(OrderDetail.class)
+ .alias("sq")
+ .where().raw("details.id = sq.id").query();
+ Query query = Ebean.find(Order.class)
+ .where().exists(subQuery)
+ .orderBy("orderDate").query();
+
+ List ids = query.findIds();
+ // TODO: assert(query.getGeneratedSql())
+ assertThat(ids).isNotEmpty();
+ FutureIds futureIds = query.findFutureIds();
+
+ // wait for all the id's to be fetched
+ List idList = futureIds.get();
+ assertThat(idList).isNotEmpty();
+ }
+
+ @Test
+ public void testFetchIdWithOrderFormula() throws InterruptedException, ExecutionException {
+
+ ResetBasicData.reset();
+
+ Query query = DB.find(Order.class).orderBy("totalItems");
+ query.findIds();
+ // TODO: assert(query.getGeneratedSql())
+ }
}
From 1f0ed629a7a11413cbb81b504df976fc250930f5 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 26 Mar 2021 20:31:03 +1300
Subject: [PATCH 002/111] Bump java8-oss to 3.1 with removal of
--illegal-access=permit argLine
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index dbd383225..297d5ab0a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.avaje
java8-oss
- 2.3
+ 3.1
io.ebean
From 819d391495166faec2b54e60a382e1c35bc11910 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Fri, 26 Mar 2021 20:31:57 +1300
Subject: [PATCH 003/111] Bump agent maven plugin to 12.8.1
---
ebean-bom/pom.xml | 4 ++--
ebean-core/pom.xml | 2 +-
ebean-ddl-generator/pom.xml | 3 +--
kotlin-querybean-generator/pom.xml | 2 +-
4 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index e96c248d7..665ea80be 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -18,8 +18,8 @@
12.4.0
4.1
7.0
- 12.6.6
- 12.6.6
+ 12.8.1
+ 12.8.1
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 9d7f1e236..e8ecd9616 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -302,7 +302,7 @@
io.ebean
ebean-maven-plugin
- 12.6.6
+ 12.8.1
test
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 1ef8c0725..60300f7ce 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -10,7 +10,6 @@
ebean ddl generation
DDL and DB Migration generation
ebean-ddl-generator
-
@@ -77,7 +76,7 @@
io.ebean
ebean-maven-plugin
- 12.6.6
+ 12.8.1
test
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index cf3dca074..588872181 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -146,7 +146,7 @@
io.ebean
ebean-maven-plugin
- 12.6.6
+ 12.8.1
test
From 5cb9b9b2372a4a8349837f6b70a43267fd61ab6d Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Mon, 29 Mar 2021 23:21:07 +1300
Subject: [PATCH 004/111] #2208 - When using fetchCache() with a single id /
findOne ... doesn't hit L2 cache
Plus #2207 ENH: Query beans add support for nested FetchGroup
---
.../io/ebeaninternal/api/CacheIdLookup.java | 47 ++------
.../ebeaninternal/api/CacheIdLookupMany.java | 55 +++++++++
.../api/CacheIdLookupSingle.java | 38 ++++++
.../io/ebeaninternal/api/SpiQueryFetch.java | 5 +
.../server/query/DefaultFetchGroupQuery.java | 5 +
.../server/querydefn/DefaultOrmQuery.java | 15 ++-
.../server/querydefn/OrmQueryProperties.java | 2 +-
.../java/io/ebean/typequery/TQAssocBean.java | 32 ++++-
.../test/java/org/querytest/QOrderTest.java | 112 ++++++++++++++++++
9 files changed, 270 insertions(+), 41 deletions(-)
create mode 100644 ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupMany.java
create mode 100644 ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupSingle.java
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookup.java b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookup.java
index 0ae791747..cf29cf6d5 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookup.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookup.java
@@ -1,52 +1,25 @@
package io.ebeaninternal.api;
-import io.ebeaninternal.server.expression.IdInExpression;
-
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
/**
- * Used for bean cache lookup with where ids in expression.
+ * Process Cache lookup by Id(s).
*/
-public class CacheIdLookup {
-
- private final IdInExpression idInExpression;
-
- private int remaining;
-
- public CacheIdLookup(IdInExpression idInExpression) {
- this.idInExpression = idInExpression;
- }
+public interface CacheIdLookup {
/**
- * Return the Id values for the in expression.
+ * Return the Id values to lookup against the L2 cache.
*/
- public Collection> idValues() {
- return idInExpression.idValues();
- }
+ Collection> idValues();
/**
- * Process the hits returning the beans fetched from cache and
- * adjusting the in expression (to not fetch the hits).
+ * Remove the hits returning the beans fetched from L2 cache.
*/
- public List removeHits(BeanCacheResult cacheResult) {
+ List removeHits(BeanCacheResult cacheResult);
- Set hitIds = new HashSet<>();
- List beans = new ArrayList<>(hitIds.size());
-
- for (BeanCacheResult.Entry hit : cacheResult.hits()) {
- hitIds.add(hit.getKey());
- beans.add(hit.getBean());
- }
-
- this.remaining = idInExpression.removeIds(hitIds);
- return beans;
- }
-
- public boolean allHits() {
- return remaining == 0;
- }
+ /**
+ * Return true if all beans where found in L2 cache.
+ */
+ boolean allHits();
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupMany.java b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupMany.java
new file mode 100644
index 000000000..bfe9d5b84
--- /dev/null
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupMany.java
@@ -0,0 +1,55 @@
+package io.ebeaninternal.api;
+
+import io.ebeaninternal.server.expression.IdInExpression;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Used for bean cache lookup with where ids in expression.
+ */
+public class CacheIdLookupMany implements CacheIdLookup {
+
+ private final IdInExpression idInExpression;
+
+ private int remaining;
+
+ public CacheIdLookupMany(IdInExpression idInExpression) {
+ this.idInExpression = idInExpression;
+ }
+
+ /**
+ * Return the Id values for the in expression.
+ */
+ @Override
+ public Collection> idValues() {
+ return idInExpression.idValues();
+ }
+
+ /**
+ * Process the hits returning the beans fetched from cache and
+ * adjusting the in expression (to not fetch the hits).
+ */
+ @Override
+ public List removeHits(BeanCacheResult cacheResult) {
+
+ Set hitIds = new HashSet<>();
+ List beans = new ArrayList<>(hitIds.size());
+
+ for (BeanCacheResult.Entry hit : cacheResult.hits()) {
+ hitIds.add(hit.getKey());
+ beans.add(hit.getBean());
+ }
+
+ this.remaining = idInExpression.removeIds(hitIds);
+ return beans;
+ }
+
+ @Override
+ public boolean allHits() {
+ return remaining == 0;
+ }
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupSingle.java b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupSingle.java
new file mode 100644
index 000000000..47ee89c4b
--- /dev/null
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/CacheIdLookupSingle.java
@@ -0,0 +1,38 @@
+package io.ebeaninternal.api;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Used for bean cache lookup with a single id value.
+ */
+public class CacheIdLookupSingle implements CacheIdLookup {
+
+ private final Object idValue;
+ private boolean found;
+
+ public CacheIdLookupSingle(Object idValue) {
+ this.idValue = idValue;
+ }
+
+ @Override
+ public Collection> idValues() {
+ return Collections.singleton(idValue);
+ }
+
+ @Override
+ public List removeHits(BeanCacheResult cacheResult) {
+ final List> hits = cacheResult.hits();
+ if (hits.size() == 1) {
+ found = true;
+ return Collections.singletonList(hits.get(0).getBean());
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
+ public boolean allHits() {
+ return found;
+ }
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java
index 396827978..716dbc076 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiQueryFetch.java
@@ -1,6 +1,7 @@
package io.ebeaninternal.api;
import io.ebean.FetchConfig;
+import io.ebeaninternal.server.querydefn.OrmQueryDetail;
import java.util.Set;
@@ -19,4 +20,8 @@ public interface SpiQueryFetch {
*/
void fetchProperties(String name, Set properties, FetchConfig config);
+ /**
+ * Add a nested fetch graph.
+ */
+ void addNested(String name, OrmQueryDetail nestedDetail, FetchConfig config);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java
index 5b2ed841a..9f7cb9b7e 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultFetchGroupQuery.java
@@ -644,4 +644,9 @@ class DefaultFetchGroupQuery implements SpiFetchGroupQuery, SpiQueryFetch
public void fetchProperties(String property, Set columns, FetchConfig config) {
detail.fetchProperties(property, columns, config);
}
+
+ @Override
+ public void addNested(String name, OrmQueryDetail nestedDetail, FetchConfig config) {
+ detail.addNested(name, nestedDetail, config);
+ }
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
index 074f364bc..867e16dfa 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
@@ -35,6 +35,8 @@ import io.ebean.plugin.BeanType;
import io.ebeaninternal.api.BindParams;
import io.ebeaninternal.api.CQueryPlanKey;
import io.ebeaninternal.api.CacheIdLookup;
+import io.ebeaninternal.api.CacheIdLookupMany;
+import io.ebeaninternal.api.CacheIdLookupSingle;
import io.ebeaninternal.api.HashQuery;
import io.ebeaninternal.api.ManyWhereJoins;
import io.ebeaninternal.api.NaturalKeyQueryData;
@@ -740,10 +742,14 @@ public class DefaultOrmQuery implements SpiQuery {
return null;
}
List underlyingList = whereExpressions.getUnderlyingList();
- if (underlyingList.size() == 1) {
+ if (underlyingList.isEmpty()) {
+ if (id != null) {
+ return new CacheIdLookupSingle<>(id);
+ }
+ } else if (underlyingList.size() == 1) {
SpiExpression singleExpression = underlyingList.get(0);
if (singleExpression instanceof IdInExpression) {
- return new CacheIdLookup<>((IdInExpression) singleExpression);
+ return new CacheIdLookupMany<>((IdInExpression) singleExpression);
}
}
return null;
@@ -1412,6 +1418,11 @@ public class DefaultOrmQuery implements SpiQuery {
detail.fetchProperties(path, other);
}
+ @Override
+ public void addNested(String name, OrmQueryDetail nestedDetail, FetchConfig config) {
+ detail.addNested(name, nestedDetail, config);
+ }
+
@Override
public Query select(String columns) {
detail.select(columns);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
index d1a3aeafc..466bb3eb9 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
@@ -120,8 +120,8 @@ public class OrmQueryProperties implements Serializable {
this.parentPath = SplitName.parent(path);
this.allProperties = other.allProperties;
this.included = other.included;
- this.cache = other.cache;
this.fetchConfig = fetchConfig;
+ this.cache = fetchConfig.isCache();
}
/**
diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java
index c54862151..d5843a612 100644
--- a/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java
+++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQAssocBean.java
@@ -2,7 +2,10 @@ package io.ebean.typequery;
import io.ebean.ExpressionList;
import io.ebean.FetchConfig;
+import io.ebean.FetchGroup;
import io.ebeaninternal.api.SpiQueryFetch;
+import io.ebeaninternal.server.querydefn.OrmQueryDetail;
+import io.ebeaninternal.server.querydefn.SpiFetchGroup;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -142,7 +145,34 @@ public abstract class TQAssocBean extends TQProperty {
return _root;
}
- private final SpiQueryFetch spiQuery() {
+ /**
+ * Fetch using the nested FetchGroup.
+ */
+ public R fetch(FetchGroup nestedGroup) {
+ return fetchNested(nestedGroup, FETCH_DEFAULT);
+ }
+
+ /**
+ * Fetch query using the nested FetchGroup.
+ */
+ public R fetchQuery(FetchGroup nestedGroup) {
+ return fetchNested(nestedGroup, FETCH_QUERY);
+ }
+
+ /**
+ * Fetch cache using the nested FetchGroup.
+ */
+ public R fetchCache(FetchGroup nestedGroup) {
+ return fetchNested(nestedGroup, FETCH_CACHE);
+ }
+
+ private R fetchNested(FetchGroup nestedGroup, FetchConfig fetchConfig) {
+ OrmQueryDetail nestedDetail = ((SpiFetchGroup) nestedGroup).underlying();
+ spiQuery().addNested(_name, nestedDetail, fetchConfig);
+ return _root;
+ }
+
+ private SpiQueryFetch spiQuery() {
return (SpiQueryFetch)((TQRootBean) _root).query();
}
diff --git a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java
index 2f470fdb5..db899549c 100644
--- a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java
+++ b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java
@@ -3,9 +3,13 @@ package org.querytest;
import io.ebean.DB;
import io.ebean.FetchGroup;
import io.ebean.test.LoggedSql;
+import org.example.domain.Customer;
import org.example.domain.Order;
+import org.example.domain.otherpackage.PhoneNumber;
import org.example.domain.query.QCustomer;
import org.example.domain.query.QOrder;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import java.util.List;
@@ -18,6 +22,26 @@ public class QOrderTest {
private static final QOrder or = QOrder.alias();
+ private static final FetchGroup fgC = QCustomer.forFetchGroup()
+ .select(cu.name, cu.phoneNumber)
+ .buildFetchGroup();
+
+ private static final FetchGroup fgNested1 = QOrder.forFetchGroup()
+ .select(or.status, or.shipDate)
+ .customer.fetch(fgC)
+ .buildFetchGroup();
+
+ private static final FetchGroup fgNested_fetchQuery = QOrder.forFetchGroup()
+ .select(or.status)
+ .customer.fetchQuery(fgC)
+ .buildFetchGroup();
+
+ private static final FetchGroup fgNested_fetchCache = QOrder.forFetchGroup()
+ .select(or.status)
+ .customer.fetchCache(fgC)
+ .buildFetchGroup();
+
+
private static final FetchGroup fg = QOrder.forFetchGroup()
.select(or.status, or.shipDate)
.customer.fetchCache(cu.name, cu.status, cu.registered, cu.comments)
@@ -28,6 +52,20 @@ public class QOrderTest {
.customer.fetch(cu.name)
.buildFetchGroup();
+ private static Order order;
+ private static Customer customer;
+
+ @BeforeClass
+ public static void before() {
+ setupData();
+ }
+
+ @AfterClass
+ public static void after() {
+ DB.delete(order);
+ DB.delete(customer);
+ }
+
@Test
public void fetchCache() {
@@ -76,6 +114,69 @@ public class QOrderTest {
assertThat(sql.get(0)).contains("select t0.id, t0.status, t1.id, t1.name from o_order t0 join be_customer t1 on t1.id = t0.customer_id where");
}
+ @Test
+ public void viaFetchGraph_withNested() {
+
+ DB.getDefault();
+ LoggedSql.start();
+
+ new QOrder()
+ .status.eq(Order.Status.NEW)
+ .select(fgNested1)
+ .findList();
+
+ final List sql = LoggedSql.stop();
+ assertThat(sql).hasSize(1);
+ assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.ship_date, t1.id, t1.name, t1.phone_number from o_order t0 join be_customer t1 on t1.id = t0.customer_id where");
+ }
+
+ @Test
+ public void viaFetchGraph_withNested_fetchQuery() {
+
+ DB.getDefault();
+ LoggedSql.start();
+
+ final Order found = new QOrder()
+ .id.eq(order.getId())
+ .select(fgNested_fetchQuery)
+ .findOne();
+
+ final List sql = LoggedSql.stop();
+
+ // assert fetching customer via fetchQuery
+ assertThat(sql).hasSize(2);
+ assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.customer_id from o_order t0 where t0.id = ?");
+ assertThat(sql.get(1)).contains("select t0.id, t0.name, t0.phone_number from be_customer t0 where t0.id = ?");
+
+ assertThat(found.getCustomer().getPhoneNumber().getMsisdn()).isEqualTo("Ph1");
+ }
+
+
+ @Test
+ public void viaFetchGraph_withNested_fetchCache() {
+
+ DB.getDefault();
+
+ // ensure the customer is loaded in the L2 cache
+ new QCustomer().id.eq(customer.getId()).findOne();
+
+ LoggedSql.start();
+
+ final Order found = new QOrder()
+ .id.eq(order.getId())
+ .select(fgNested_fetchCache) // cache hit for customer
+ .findOne();
+
+ final String msisdn = found.getCustomer().getPhoneNumber().getMsisdn();
+ assertThat(msisdn).isEqualTo("Ph1");
+
+ final List sql = LoggedSql.stop();
+
+ // assert we only hit DB for order
+ assertThat(sql).hasSize(1);
+ assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.customer_id from o_order t0 where t0.id = ?");
+ }
+
@Test
public void select_partial() {
@@ -113,4 +214,15 @@ public class QOrderTest {
}
+ private static void setupData() {
+
+ customer = new Customer();
+ customer.setName("Fred");
+ customer.setPhoneNumber(new PhoneNumber("Ph1"));
+ customer.save();
+
+ order = new Order();
+ order.setCustomer(customer);
+ order.save();
+ }
}
From d988dbe69def32b5bdb3f185e9470df8bab3047a Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Tue, 30 Mar 2021 09:56:48 +1300
Subject: [PATCH 005/111] #2209 - Registering [default] as the default server
but [default] is already registered as the default exception with hot-reload
---
ebean-api/src/main/java/io/ebean/DatabaseFactory.java | 2 +-
ebean-core/src/test/java/org/MainMemoryLeak.java | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
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-core/src/test/java/org/MainMemoryLeak.java b/ebean-core/src/test/java/org/MainMemoryLeak.java
index d3f085ef3..b659297b4 100644
--- a/ebean-core/src/test/java/org/MainMemoryLeak.java
+++ b/ebean-core/src/test/java/org/MainMemoryLeak.java
@@ -46,7 +46,12 @@ public class MainMemoryLeak {
config.addClass(ECachedBean.class);
config.loadFromProperties();
+ Database server1 = DatabaseFactory.create(config);
+ assert server1 != null;
+
+ // create again for #2193
Database server = DatabaseFactory.create(config);
+ assert server != null;
// create a string with 10k chars
char[] c = new char[10_000];
From f8c37772d4bc518c89a3ff26d3cc00ea7905466c Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Tue, 30 Mar 2021 10:23:28 +1300
Subject: [PATCH 006/111] Tidy internals of DefaultServer with @Nonnull, <>,
Collections.singleton(), remove unused queryBatchSize
---
.../server/core/DefaultServer.java | 39 +++++++++++--------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
index 34a094301..5e8db9c1c 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
@@ -125,6 +125,7 @@ import io.ebeanservice.docstore.api.DocStoreIntegration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
import javax.persistence.NonUniqueResultException;
import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceException;
@@ -137,7 +138,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -196,7 +196,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
private final SpiLogManager logManager;
private final PersistenceContextScope defaultPersistenceContextScope;
private final int lazyLoadBatchSize;
- private final int queryBatchSize;
private final boolean updateAllPropertiesInBatch;
private final long slowQueryMicros;
private final SlowQueryListener slowQueryListener;
@@ -217,7 +216,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
this.extraMetrics = config.getExtraMetrics();
this.serverName = this.config.getName();
this.lazyLoadBatchSize = this.config.getLazyLoadBatchSize();
- this.queryBatchSize = this.config.getQueryBatchSize();
this.cqueryEngine = config.getCQueryEngine();
this.expressionFactory = config.getExpressionFactory();
this.encryptKeyManager = this.config.getEncryptKeyManager();
@@ -305,10 +303,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
return lazyLoadBatchSize;
}
- public int getQueryBatchSize() {
- return queryBatchSize;
- }
-
@Override
public Object currentTenantId() {
return currentTenantProvider == null ? null : currentTenantProvider.currentId();
@@ -1150,6 +1144,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
+ @Nonnull
@Override
public Optional findOneOrEmpty(Query query, Transaction transaction) {
return Optional.ofNullable(findOne(query, transaction));
@@ -1180,6 +1175,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
+ @Nonnull
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Set findSet(Query query, Transaction t) {
@@ -1196,6 +1192,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
+ @Nonnull
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Map findMap(Query query, Transaction t) {
@@ -1217,6 +1214,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
+ @Nonnull
@Override
@SuppressWarnings("unchecked")
public List findSingleAttributeList(Query query, Transaction t) {
@@ -1227,7 +1225,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
try {
request.initTransIfRequired();
- return (List) request.findSingleAttributeList();
+ return request.findSingleAttributeList();
} finally {
request.endTransIfRequired();
}
@@ -1277,6 +1275,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
+ @Nonnull
@Override
public List findIds(Query query, Transaction t) {
return findIdsWithCopy(((SpiQuery) query).copy(), t);
@@ -1337,26 +1336,29 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
+ @Nonnull
@Override
public FutureRowCount findFutureCount(Query q, Transaction t) {
SpiQuery copy = ((SpiQuery) q).copy();
copy.setFutureFetch(true);
Transaction newTxn = createTransaction();
- QueryFutureRowCount queryFuture = new QueryFutureRowCount<>(new CallableQueryCount(this, copy, newTxn));
+ QueryFutureRowCount queryFuture = new QueryFutureRowCount<>(new CallableQueryCount<>(this, copy, newTxn));
backgroundExecutor.execute(queryFuture.getFutureTask());
return queryFuture;
}
+ @Nonnull
@Override
public FutureIds findFutureIds(Query query, Transaction t) {
SpiQuery copy = ((SpiQuery) query).copy();
copy.setFutureFetch(true);
Transaction newTxn = createTransaction();
- QueryFutureIds queryFuture = new QueryFutureIds<>(new CallableQueryIds(this, copy, newTxn));
+ QueryFutureIds queryFuture = new QueryFutureIds<>(new CallableQueryIds<>(this, copy, newTxn));
backgroundExecutor.execute(queryFuture.getFutureTask());
return queryFuture;
}
+ @Nonnull
@Override
public FutureList findFutureList(Query query, Transaction t) {
SpiQuery spiQuery = (SpiQuery) query;
@@ -1369,11 +1371,12 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
// Create a new transaction solely to execute the findList() at some future time
Transaction newTxn = createTransaction();
- QueryFutureList queryFuture = new QueryFutureList<>(new CallableQueryList(this, spiQuery, newTxn));
+ QueryFutureList queryFuture = new QueryFutureList<>(new CallableQueryList<>(this, spiQuery, newTxn));
backgroundExecutor.execute(queryFuture.getFutureTask());
return queryFuture;
}
+ @Nonnull
@Override
public PagedList findPagedList(Query query, Transaction transaction) {
SpiQuery spiQuery = (SpiQuery) query;
@@ -1387,6 +1390,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
return new LimitOffsetPagedList<>(this, spiQuery);
}
+ @Nonnull
@Override
public QueryIterator findIterate(Query query, Transaction t) {
SpiOrmQueryRequest request = createQueryRequest(Type.ITERATE, query, t);
@@ -1399,11 +1403,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
+ @Nonnull
@Override
public Stream findLargeStream(Query query, Transaction transaction) {
return findStream(query, transaction);
}
+ @Nonnull
@Override
public Stream findStream(Query query, Transaction transaction) {
SpiOrmQueryRequest request = createQueryRequest(Type.ITERATE, query, transaction);
@@ -1470,6 +1476,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
// no try finally - findEachWhile guarantee's cleanup of the transaction if required
}
+ @Nonnull
@Override
public List> findVersions(Query query, Transaction transaction) {
SpiOrmQueryRequest request = createQueryRequest(Type.LIST, query, transaction);
@@ -1481,6 +1488,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
+ @Nonnull
@Override
public List findList(Query query, Transaction t) {
return findList(query, t, false);
@@ -1540,6 +1548,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
}
+ @Nonnull
@Override
public List findList(SqlQuery query, Transaction t) {
RelationalQueryRequest request = new RelationalQueryRequest(this, relationalQueryEngine, query, t);
@@ -2241,6 +2250,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
return checkUniqueness(bean, null);
}
+ @Nonnull
@Override
public Set checkUniqueness(Object bean, Transaction transaction) {
EntityBean entityBean = checkEntityBean(bean);
@@ -2252,14 +2262,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
Object id = idProperty.getVal(entityBean);
if (entityBean._ebean_getIntercept().isNew() && id != null) {
- // Primary Key is changeable only on new models - so skip check if we are not
- // new.
+ // Primary Key is changeable only on new models - so skip check if we are not new
Query> query = new DefaultOrmQuery<>(beanDesc, this, expressionFactory);
query.setId(id);
if (findCount(query, transaction) > 0) {
- Set ret = new HashSet<>();
- ret.add(idProperty);
- return ret;
+ return Collections.singleton(idProperty);
}
}
for (BeanProperty[] props : beanDesc.getUniqueProps()) {
From 2a5fd7f3a993909cf9a2a8c53a3b8d302a71d582 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Tue, 30 Mar 2021 16:02:27 +1300
Subject: [PATCH 007/111] #2210 - Improve query plan capture - ability to
change default threshold micros
---
.../java/io/ebean/meta/QueryPlanRequest.java | 7 +++++-
.../api/NoopQueryPlanManager.java | 5 ++++
.../ebeaninternal/api/QueryPlanManager.java | 5 ++++
.../server/core/DefaultServer.java | 3 +++
.../server/query/CQueryPlanManager.java | 9 +++++--
.../query/finder/TestCustomerFinder.java | 24 +++++++++++++++----
6 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/ebean-api/src/main/java/io/ebean/meta/QueryPlanRequest.java b/ebean-api/src/main/java/io/ebean/meta/QueryPlanRequest.java
index 3510b30cc..c4a69b1aa 100644
--- a/ebean-api/src/main/java/io/ebean/meta/QueryPlanRequest.java
+++ b/ebean-api/src/main/java/io/ebean/meta/QueryPlanRequest.java
@@ -41,6 +41,9 @@ public class QueryPlanRequest {
/**
* Set the maximum number of plans to capture.
+ *
+ * Use this to limit how much query plan capturing is done as query
+ * plan capture is actual database load.
*/
public void setMaxCount(int maxCount) {
this.maxCount = maxCount;
@@ -58,7 +61,9 @@ public class QueryPlanRequest {
/**
* Set the maximum amount of time we want to use to capture plans.
*
- * Query plan collection will stop once this time is exceeded.
+ * Query plan collection will stop once this time is exceeded. We use
+ * this to ensure the query plan capture does not use excessive amount
+ * of time - put too much load on the database.
*/
public void setMaxTimeMillis(long maxTimeMillis) {
this.maxTimeMillis = maxTimeMillis;
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/NoopQueryPlanManager.java b/ebean-core/src/main/java/io/ebeaninternal/api/NoopQueryPlanManager.java
index e00ad57f1..813121f92 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/NoopQueryPlanManager.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/NoopQueryPlanManager.java
@@ -8,6 +8,11 @@ import java.util.List;
class NoopQueryPlanManager implements QueryPlanManager {
+ @Override
+ public void setDefaultThreshold(long thresholdMicros) {
+ // do nothing
+ }
+
@Override
public SpiQueryBindCapture createBindCapture(SpiQueryPlan queryPlan) {
return SpiQueryBindCapture.NOOP;
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/QueryPlanManager.java b/ebean-core/src/main/java/io/ebeaninternal/api/QueryPlanManager.java
index f9750c47a..da7ce2b43 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/QueryPlanManager.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/QueryPlanManager.java
@@ -12,6 +12,11 @@ public interface QueryPlanManager {
QueryPlanManager NOOP = new NoopQueryPlanManager();
+ /**
+ * Update the global default threshold used when new query plans are created.
+ */
+ void setDefaultThreshold(long thresholdMicros);
+
/**
* Create the bind capture for the given query plan.
*/
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
index 5e8db9c1c..0e4d22768 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
@@ -2329,6 +2329,9 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
}
List queryPlanInit(QueryPlanInit initRequest) {
+ if (initRequest.isAll()) {
+ queryPlanManager.setDefaultThreshold(initRequest.getThresholdMicros());
+ }
return beanDescriptorManager.queryPlanInit(initRequest);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlanManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlanManager.java
index c2e6aa358..4ff62f44d 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlanManager.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPlanManager.java
@@ -30,14 +30,14 @@ public class CQueryPlanManager implements QueryPlanManager {
private final TransactionManager transactionManager;
- private final long defaultThreshold;
-
private final QueryPlanLogger planLogger;
private final TimedMetric timeCollection;
private final TimedMetric timeBindCapture;
+ private long defaultThreshold;
+
public CQueryPlanManager(TransactionManager transactionManager, long defaultThreshold, QueryPlanLogger planLogger, ExtraMetrics extraMetrics) {
this.transactionManager = transactionManager;
this.defaultThreshold = defaultThreshold;
@@ -46,6 +46,11 @@ public class CQueryPlanManager implements QueryPlanManager {
this.timeBindCapture = extraMetrics.getBindCapture();
}
+ @Override
+ public void setDefaultThreshold(long thresholdMicros) {
+ this.defaultThreshold = thresholdMicros;
+ }
+
@Override
public SpiQueryBindCapture createBindCapture(SpiQueryPlan queryPlan) {
return new CQueryBindCapture(this, queryPlan, defaultThreshold);
diff --git a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java
index 48cc264c6..8446f9d5b 100644
--- a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java
+++ b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java
@@ -175,17 +175,24 @@ public class TestCustomerFinder extends BaseTestCase {
ResetBasicData.reset();
+ // change default collect query plan threshold to 200 micros
+ QueryPlanInit init0 = new QueryPlanInit();
+ init0.setAll(true);
+ init0.setThresholdMicros(200);
+ final List plans = server().getMetaInfoManager().queryPlanInit(init0);
+ assertThat(plans.size()).isGreaterThan(1);
+
// the server has some plans
runQueries();
- // enable query plan bind capture on all plans threshold 100 micros
+ // change query plan threshold to 100 micros
QueryPlanInit init = new QueryPlanInit();
init.setAll(true);
init.setThresholdMicros(100);
final List appliedToPlans = server().getMetaInfoManager().queryPlanInit(init);
assertThat(appliedToPlans.size()).isGreaterThan(4);
- // will collect bind captures
+ // run queries again
runQueries();
ServerMetrics metrics = server().getMetaInfoManager().collectMetrics();
@@ -203,12 +210,21 @@ public class TestCustomerFinder extends BaseTestCase {
// obtains db query plans ...
QueryPlanRequest request = new QueryPlanRequest();
- List plans = server().getMetaInfoManager().queryPlanCollectNow(request);
- assertThat(plans).isNotEmpty();
+ // collect max 1000 plans (use something more like 10)
+ request.setMaxCount(1_000);
+ // don't collect any more plans if used 10 secs
+ request.setMaxTimeMillis(10_000);
+ List plans0 = server().getMetaInfoManager().queryPlanCollectNow(request);
+ assertThat(plans0).isNotEmpty();
for (MetaQueryPlan plan : plans) {
+ logger.info("queryplan label:{}, queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
+ plan.getLabel(), plan.getQueryTimeMicros(), plan.getProfileLocation(),
+ plan.getSql(), plan.getBind(), plan.getPlan());
System.out.println(plan);
}
+
+ //DB.getBackgroundExecutor().scheduleWithFixedDelay(...)
}
@Test
From bcfd9cab1db0a5b81b9e71b2c07adc9bdfa2ed52 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Tue, 30 Mar 2021 16:05:42 +1300
Subject: [PATCH 008/111] #2210 - Improve query plan capture - bump threshold
multiplier to 1.5
---
.../java/io/ebeaninternal/server/query/CQueryBindCapture.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java
index 713169640..e3a1a5e54 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryBindCapture.java
@@ -9,7 +9,7 @@ import java.util.concurrent.locks.ReentrantLock;
class CQueryBindCapture implements SpiQueryBindCapture {
- private static final double multiplier = 1.3d;
+ private static final double multiplier = 1.5d;
private final ReentrantLock lock = new ReentrantLock();
private final CQueryPlanManager manager;
From ee8bb5ef751ccbc9cd9b1d6fdd0b561ec8e781a7 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Tue, 30 Mar 2021 23:19:21 +1300
Subject: [PATCH 009/111] #2211 - Improve query plan capture - Add default
mechanism to log captured query plans
---
.../java/io/ebean/config/DatabaseConfig.java | 94 ++++++++++++++++++-
.../io/ebean/config/QueryPlanCapture.java | 34 +++++++
.../io/ebean/config/QueryPlanListener.java | 13 +++
.../server/core/DefaultQueryPlanListener.java | 25 +++++
.../server/core/DefaultServer.java | 33 +++++--
.../io/ebean/config/ServerConfigTest.java | 15 +++
6 files changed, 206 insertions(+), 8 deletions(-)
create mode 100644 ebean-api/src/main/java/io/ebean/config/QueryPlanCapture.java
create mode 100644 ebean-api/src/main/java/io/ebean/config/QueryPlanListener.java
create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultQueryPlanListener.java
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 49c458743..1cbfa9d3e 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
@@ -498,7 +498,7 @@ public class DatabaseConfig {
private boolean notifyL2CacheInForeground;
/**
- * Set to true to support query plan capture.
+ * Set to true to enable bind capture required for query plan capture.
*/
private boolean collectQueryPlans;
@@ -507,6 +507,15 @@ public class DatabaseConfig {
*/
private long collectQueryPlanThresholdMicros = Long.MAX_VALUE;
+ /**
+ * Set to true to enable automatic query plan capture.
+ */
+ private boolean queryPlanCapture;
+ private long queryPlanCapturePeriodSecs = 60 * 10; // 10 minutes
+ private long queryPlanCaptureMaxTimeMillis = 10_000; // 10 seconds
+ private int queryPlanCaptureMaxCount = 10;
+ private QueryPlanListener queryPlanListener;
+
/**
* The time in millis used to determine when a query is alerted for being slow.
*/
@@ -1045,7 +1054,6 @@ public class DatabaseConfig {
* This is a performance optimisation to reduce the number times Ebean
* requests a sequence to be used as an Id for a bean (aka reduce network
* chatter).
-
*/
public void setDatabaseSequenceBatchSize(int databaseSequenceBatchSize) {
platformConfig.setDatabaseSequenceBatchSize(databaseSequenceBatchSize);
@@ -2807,6 +2815,10 @@ public class DatabaseConfig {
slowQueryMillis = p.getLong("slowQueryMillis", slowQueryMillis);
collectQueryPlans = p.getBoolean("collectQueryPlans", collectQueryPlans);
collectQueryPlanThresholdMicros = p.getLong("collectQueryPlanThresholdMicros", collectQueryPlanThresholdMicros);
+ queryPlanCapture = p.getBoolean("queryPlan.capture", queryPlanCapture);
+ queryPlanCapturePeriodSecs = p.getLong("queryPlan.capturePeriodSecs", queryPlanCapturePeriodSecs);
+ queryPlanCaptureMaxTimeMillis = p.getLong("queryPlan.captureMaxTimeMillis", queryPlanCaptureMaxTimeMillis);
+ queryPlanCaptureMaxCount = p.getInt("queryPlan.captureMaxCount", queryPlanCaptureMaxCount);
docStoreOnly = p.getBoolean("docStoreOnly", docStoreOnly);
disableL2Cache = p.getBoolean("disableL2Cache", disableL2Cache);
localOnlyL2Cache = p.getBoolean("localOnlyL2Cache", localOnlyL2Cache);
@@ -3201,6 +3213,84 @@ public class DatabaseConfig {
this.collectQueryPlanThresholdMicros = collectQueryPlanThresholdMicros;
}
+ /**
+ * Return true if periodic capture of query plans is enabled.
+ */
+ public boolean isQueryPlanCapture() {
+ return queryPlanCapture;
+ }
+
+ /**
+ * Set to true to turn on periodic capture of query plans.
+ */
+ public void setQueryPlanCapture(boolean queryPlanCapture) {
+ this.queryPlanCapture = queryPlanCapture;
+ }
+
+ /**
+ * Return the frequency to capture query plans.
+ */
+ public long getQueryPlanCapturePeriodSecs() {
+ return queryPlanCapturePeriodSecs;
+ }
+
+ /**
+ * Set the frequency in seconds to capture query plans.
+ */
+ public void setQueryPlanCapturePeriodSecs(long queryPlanCapturePeriodSecs) {
+ this.queryPlanCapturePeriodSecs = queryPlanCapturePeriodSecs;
+ }
+
+ /**
+ * Return the time after which a capture query plans request will
+ * stop capturing more query plans.
+ *
+ * Effectively this controls the amount of load/time we want to
+ * allow for query plan capture.
+ */
+ public long getQueryPlanCaptureMaxTimeMillis() {
+ return queryPlanCaptureMaxTimeMillis;
+ }
+
+ /**
+ * Set the time after which a capture query plans request will
+ * stop capturing more query plans.
+ *
+ * Effectively this controls the amount of load/time we want to
+ * allow for query plan capture.
+ */
+ public void setQueryPlanCaptureMaxTimeMillis(long queryPlanCaptureMaxTimeMillis) {
+ this.queryPlanCaptureMaxTimeMillis = queryPlanCaptureMaxTimeMillis;
+ }
+
+ /**
+ * Return the max number of query plans captured per request.
+ */
+ public int getQueryPlanCaptureMaxCount() {
+ return queryPlanCaptureMaxCount;
+ }
+
+ /**
+ * Set the max number of query plans captured per request.
+ */
+ public void setQueryPlanCaptureMaxCount(int queryPlanCaptureMaxCount) {
+ this.queryPlanCaptureMaxCount = queryPlanCaptureMaxCount;
+ }
+
+ /**
+ * Return the listener used to process captured query plans.
+ */
+ public QueryPlanListener getQueryPlanListener() {
+ return queryPlanListener;
+ }
+
+ /**
+ * Set the listener used to process captured query plans.
+ */
+ public void setQueryPlanListener(QueryPlanListener queryPlanListener) {
+ this.queryPlanListener = queryPlanListener;
+ }
+
/**
* Return true if metrics should be dumped when the server is shutdown.
*/
diff --git a/ebean-api/src/main/java/io/ebean/config/QueryPlanCapture.java b/ebean-api/src/main/java/io/ebean/config/QueryPlanCapture.java
new file mode 100644
index 000000000..6f34097fe
--- /dev/null
+++ b/ebean-api/src/main/java/io/ebean/config/QueryPlanCapture.java
@@ -0,0 +1,34 @@
+package io.ebean.config;
+
+import io.ebean.Database;
+import io.ebean.meta.MetaQueryPlan;
+
+import java.util.List;
+
+/**
+ * The captured query plans.
+ */
+public class QueryPlanCapture {
+
+ private final Database database;
+ private final List plans;
+
+ public QueryPlanCapture(Database database, List plans) {
+ this.database = database;
+ this.plans = plans;
+ }
+
+ /**
+ * Return the database the plans were captured for.
+ */
+ public Database getDatabase() {
+ return database;
+ }
+
+ /**
+ * Return the captured query plans.
+ */
+ public List getPlans() {
+ return plans;
+ }
+}
diff --git a/ebean-api/src/main/java/io/ebean/config/QueryPlanListener.java b/ebean-api/src/main/java/io/ebean/config/QueryPlanListener.java
new file mode 100644
index 000000000..8368186cf
--- /dev/null
+++ b/ebean-api/src/main/java/io/ebean/config/QueryPlanListener.java
@@ -0,0 +1,13 @@
+package io.ebean.config;
+
+/**
+ * EXPERIMENTAL: Listener for captured query plans.
+ */
+@FunctionalInterface
+public interface QueryPlanListener {
+
+ /**
+ * Process the captured query plans.
+ */
+ void process(QueryPlanCapture capture);
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultQueryPlanListener.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultQueryPlanListener.java
new file mode 100644
index 000000000..051d331ba
--- /dev/null
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultQueryPlanListener.java
@@ -0,0 +1,25 @@
+package io.ebeaninternal.server.core;
+
+import io.ebean.config.QueryPlanCapture;
+import io.ebean.config.QueryPlanListener;
+import io.ebean.meta.MetaQueryPlan;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class DefaultQueryPlanListener implements QueryPlanListener {
+
+ static final QueryPlanListener INSTANT = new DefaultQueryPlanListener();
+
+ private static final Logger log = LoggerFactory.getLogger("io.ebean.QUERYPLAN");
+
+ @Override
+ public void process(QueryPlanCapture capture) {
+ // better to log this in JSON form?
+ String dbName = capture.getDatabase().getName();
+ for (MetaQueryPlan plan : capture.getPlans()) {
+ log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
+ dbName, plan.getLabel(), plan.getQueryTimeMicros(), plan.getProfileLocation(),
+ plan.getSql(), plan.getBind(), plan.getPlan());
+ }
+ }
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
index 0e4d22768..52b94bfb6 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
@@ -45,12 +45,7 @@ import io.ebean.bean.PersistenceContext.WithOption;
import io.ebean.bean.SingleBeanLoader;
import io.ebean.cache.ServerCacheManager;
import io.ebean.common.CopyOnFirstWriteList;
-import io.ebean.config.CurrentTenantProvider;
-import io.ebean.config.DatabaseConfig;
-import io.ebean.config.EncryptKeyManager;
-import io.ebean.config.SlowQueryEvent;
-import io.ebean.config.SlowQueryListener;
-import io.ebean.config.TenantMode;
+import io.ebean.config.*;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.event.BeanPersistController;
import io.ebean.event.ShutdownManager;
@@ -145,6 +140,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.Spliterator;
import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -404,6 +400,31 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
migrationRunner.loadProperties(config.getProperties());
migrationRunner.run(config.getDataSource());
}
+ startQueryPlanCapture();
+ }
+
+ private void startQueryPlanCapture() {
+ if (config.isQueryPlanCapture()) {
+ long secs = config.getQueryPlanCapturePeriodSecs();
+ if (secs > 10) {
+ logger.info("capture query plan enabled, every {}secs", secs);
+ backgroundExecutor.scheduleWithFixedDelay(this::collectQueryPlans, secs, secs, TimeUnit.SECONDS);
+ }
+ }
+ }
+
+ private void collectQueryPlans() {
+ QueryPlanRequest request = new QueryPlanRequest();
+ request.setMaxCount(config.getQueryPlanCaptureMaxCount());
+ request.setMaxTimeMillis(config.getQueryPlanCaptureMaxTimeMillis());
+
+ // obtains query explain plans ...
+ List plans = metaInfoManager.queryPlanCollectNow(request);
+ QueryPlanListener listener = config.getQueryPlanListener();
+ if (listener == null) {
+ listener = DefaultQueryPlanListener.INSTANT;
+ }
+ listener.process(new QueryPlanCapture(this, plans));
}
@Override
diff --git a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
index 8fda93985..b23ccdbb6 100644
--- a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
+++ b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
@@ -76,6 +76,11 @@ public class ServerConfigTest {
props.setProperty("forUpdateNoKey", "true");
props.setProperty("defaultServer", "false");
+ props.setProperty("queryPlan.capture", "true");
+ props.setProperty("queryPlan.capturePeriodSecs", "42");
+ props.setProperty("queryPlan.captureMaxTimeMillis", "560");
+ props.setProperty("queryPlan.captureMaxCount", "7");
+
serverConfig.loadFromProperties(props);
assertFalse(serverConfig.isDefaultServer());
@@ -106,6 +111,11 @@ public class ServerConfigTest {
assertEquals(4, serverConfig.getBackgroundExecutorSchedulePoolSize());
assertEquals(98, serverConfig.getBackgroundExecutorShutdownSecs());
+ assertTrue(serverConfig.isQueryPlanCapture());
+ assertEquals(42, serverConfig.getQueryPlanCapturePeriodSecs());
+ assertEquals(560, serverConfig.getQueryPlanCaptureMaxTimeMillis());
+ assertEquals(7, serverConfig.getQueryPlanCaptureMaxCount());
+
assertThat(serverConfig.getMappingLocations()).containsExactly("classpath:/foo","bar");
serverConfig.setPersistBatch(PersistBatch.NONE);
@@ -146,6 +156,11 @@ public class ServerConfigTest {
assertTrue(serverConfig.isAutoLoadModuleInfo());
assertEquals(Long.MAX_VALUE, serverConfig.getCollectQueryPlanThresholdMicros());
+ assertFalse(serverConfig.isQueryPlanCapture());
+ assertEquals(600, serverConfig.getQueryPlanCapturePeriodSecs());
+ assertEquals(10000L, serverConfig.getQueryPlanCaptureMaxTimeMillis());
+ assertEquals(10, serverConfig.getQueryPlanCaptureMaxCount());
+
serverConfig.setLoadModuleInfo(false);
assertFalse(serverConfig.isAutoLoadModuleInfo());
}
From a8bf27da550e9438e8195c3162c91ed840c5cfc1 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Tue, 30 Mar 2021 23:44:30 +1300
Subject: [PATCH 010/111] #2211 - Improve query plan capture - Align config
property names
collectQueryPlans -> queryPlanEnable
collectQueryPlanThresholdMicros -> queryPlanThresholdMicros
properties keys:
ebean.collectQueryPlans -> ebean.queryPlan.enable
ebean.collectQueryPlanThresholdMicros -> ebean.queryPlan.thresholdMicros
This then aligns all the queryPlan related properties together which is important in order to avoid confusion.
---
.../java/io/ebean/config/DatabaseConfig.java | 29 ++++++++++---------
.../server/core/InternalConfiguration.java | 4 +--
.../io/ebean/config/ServerConfigTest.java | 9 ++++--
.../src/test/resources/ebean.properties | 4 +--
4 files changed, 26 insertions(+), 20 deletions(-)
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 1cbfa9d3e..c4195f0be 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
@@ -500,15 +500,15 @@ public class DatabaseConfig {
/**
* Set to true to enable bind capture required for query plan capture.
*/
- private boolean collectQueryPlans;
+ private boolean queryPlanEnable;
/**
* The default threshold in micros for collecting query plans.
*/
- private long collectQueryPlanThresholdMicros = Long.MAX_VALUE;
+ private long queryPlanThresholdMicros = Long.MAX_VALUE;
/**
- * Set to true to enable automatic query plan capture.
+ * Set to true to enable automatic periodic query plan capture.
*/
private boolean queryPlanCapture;
private long queryPlanCapturePeriodSecs = 60 * 10; // 10 minutes
@@ -2813,8 +2813,8 @@ public class DatabaseConfig {
dumpMetricsOptions = p.get("dumpMetricsOptions", dumpMetricsOptions);
queryPlanTTLSeconds = p.getInt("queryPlanTTLSeconds", queryPlanTTLSeconds);
slowQueryMillis = p.getLong("slowQueryMillis", slowQueryMillis);
- collectQueryPlans = p.getBoolean("collectQueryPlans", collectQueryPlans);
- collectQueryPlanThresholdMicros = p.getLong("collectQueryPlanThresholdMicros", collectQueryPlanThresholdMicros);
+ queryPlanEnable = p.getBoolean("queryPlan.enable", queryPlanEnable);
+ queryPlanThresholdMicros = p.getLong("queryPlan.thresholdMicros", queryPlanThresholdMicros);
queryPlanCapture = p.getBoolean("queryPlan.capture", queryPlanCapture);
queryPlanCapturePeriodSecs = p.getLong("queryPlan.capturePeriodSecs", queryPlanCapturePeriodSecs);
queryPlanCaptureMaxTimeMillis = p.getLong("queryPlan.captureMaxTimeMillis", queryPlanCaptureMaxTimeMillis);
@@ -3188,29 +3188,32 @@ public class DatabaseConfig {
/**
* Return true if query plan capture is enabled.
*/
- public boolean isCollectQueryPlans() {
- return collectQueryPlans;
+ public boolean isQueryPlanEnable() {
+ return queryPlanEnable;
}
/**
* Set to true to enable query plan capture.
*/
- public void setCollectQueryPlans(boolean collectQueryPlans) {
- this.collectQueryPlans = collectQueryPlans;
+ public void setQueryPlanEnable(boolean queryPlanEnable) {
+ this.queryPlanEnable = queryPlanEnable;
}
/**
* Return the query plan collection threshold in microseconds.
*/
- public long getCollectQueryPlanThresholdMicros() {
- return collectQueryPlanThresholdMicros;
+ public long getQueryPlanThresholdMicros() {
+ return queryPlanThresholdMicros;
}
/**
* Set the query plan collection threshold in microseconds.
+ *
+ * Queries executing slower than this will have bind values captured such that later
+ * the query plan can be captured and reported.
*/
- public void setCollectQueryPlanThresholdMicros(long collectQueryPlanThresholdMicros) {
- this.collectQueryPlanThresholdMicros = collectQueryPlanThresholdMicros;
+ public void setQueryPlanThresholdMicros(long queryPlanThresholdMicros) {
+ this.queryPlanThresholdMicros = queryPlanThresholdMicros;
}
/**
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
index 56ea7589a..8cbbbfa4b 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
@@ -617,10 +617,10 @@ public class InternalConfiguration {
}
public QueryPlanManager initQueryPlanManager(TransactionManager transactionManager) {
- if (!config.isCollectQueryPlans()) {
+ if (!config.isQueryPlanEnable()) {
return QueryPlanManager.NOOP;
}
- long threshold = config.getCollectQueryPlanThresholdMicros();
+ long threshold = config.getQueryPlanThresholdMicros();
return new CQueryPlanManager(transactionManager, threshold, queryPlanLogger(databasePlatform.getPlatform()), extraMetrics);
}
diff --git a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
index b23ccdbb6..f93c18d26 100644
--- a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
+++ b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
@@ -72,10 +72,11 @@ public class ServerConfigTest {
props.setProperty("enabledL2Regions", "r0,users,orgs");
props.setProperty("caseSensitiveCollation", "false");
props.setProperty("loadModuleInfo", "true");
- props.setProperty("collectQueryPlanThresholdMicros", "10000");
props.setProperty("forUpdateNoKey", "true");
props.setProperty("defaultServer", "false");
+ props.setProperty("queryPlan.enable", "true");
+ props.setProperty("queryPlan.thresholdMicros", "10000");
props.setProperty("queryPlan.capture", "true");
props.setProperty("queryPlan.capturePeriodSecs", "42");
props.setProperty("queryPlan.captureMaxTimeMillis", "560");
@@ -102,7 +103,6 @@ public class ServerConfigTest {
assertEquals(PlatformConfig.DbUuid.BINARY, serverConfig.getPlatformConfig().getDbUuid());
assertEquals(JsonConfig.DateTime.MILLIS, serverConfig.getJsonDateTime());
assertEquals(JsonConfig.Date.MILLIS, serverConfig.getJsonDate());
- assertEquals(10000, serverConfig.getCollectQueryPlanThresholdMicros());
assertEquals("r0,users,orgs", serverConfig.getEnabledL2Regions());
@@ -111,6 +111,8 @@ public class ServerConfigTest {
assertEquals(4, serverConfig.getBackgroundExecutorSchedulePoolSize());
assertEquals(98, serverConfig.getBackgroundExecutorShutdownSecs());
+ assertTrue(serverConfig.isQueryPlanEnable());
+ assertEquals(10000, serverConfig.getQueryPlanThresholdMicros());
assertTrue(serverConfig.isQueryPlanCapture());
assertEquals(42, serverConfig.getQueryPlanCapturePeriodSecs());
assertEquals(560, serverConfig.getQueryPlanCaptureMaxTimeMillis());
@@ -154,8 +156,9 @@ public class ServerConfigTest {
assertEquals(JsonConfig.Date.ISO8601, serverConfig.getJsonDate());
assertTrue(serverConfig.getPlatformConfig().isCaseSensitiveCollation());
assertTrue(serverConfig.isAutoLoadModuleInfo());
- assertEquals(Long.MAX_VALUE, serverConfig.getCollectQueryPlanThresholdMicros());
+ assertFalse(serverConfig.isQueryPlanEnable());
+ assertEquals(Long.MAX_VALUE, serverConfig.getQueryPlanThresholdMicros());
assertFalse(serverConfig.isQueryPlanCapture());
assertEquals(600, serverConfig.getQueryPlanCapturePeriodSecs());
assertEquals(10000L, serverConfig.getQueryPlanCaptureMaxTimeMillis());
diff --git a/ebean-core/src/test/resources/ebean.properties b/ebean-core/src/test/resources/ebean.properties
index 953d2c720..aa1210739 100644
--- a/ebean-core/src/test/resources/ebean.properties
+++ b/ebean-core/src/test/resources/ebean.properties
@@ -27,8 +27,8 @@ datasource.default=h2
ebean.dumpMetricsOnShutdown=true
ebean.dumpMetricsOptions=sql,hash
-#ebean.collectQueryPlanThresholdMicros=1000
-ebean.collectQueryPlans=true
+#ebean.queryPlan.thresholdMicros=1000
+ebean.queryPlan.enable=true
ebean.autoReadOnlyDataSource=true
#datasource.h2-ro.url=jdbc:h2:mem:tests
From 1bf09ddd38c39f7814815ae88ee1072e994101a3 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Tue, 30 Mar 2021 23:49:44 +1300
Subject: [PATCH 011/111] #2211 - Improve javadoc for queryPlanTTLSeconds
Hopefully people understand it is unrelated. Unfortunately we now have some properties with similar names so maybe we need a better name for this sometime in the future.
---
.../src/main/java/io/ebean/config/DatabaseConfig.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
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 c4195f0be..bf4c61675 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
@@ -3108,14 +3108,17 @@ public class DatabaseConfig {
}
/**
- * Return the query plan time to live.
+ * Return the time to live for ebean's internal query plan.
*/
public int getQueryPlanTTLSeconds() {
return queryPlanTTLSeconds;
}
/**
- * Set the query plan time to live.
+ * Set the time to live for ebean's internal query plan.
+ *
+ * This is the plan that knows how to execute the query, read the result
+ * and collects execution metrics. By default this is set to 5 mins.
*/
public void setQueryPlanTTLSeconds(int queryPlanTTLSeconds) {
this.queryPlanTTLSeconds = queryPlanTTLSeconds;
From f7035eb2289c035c2f762166118c76c01a056051 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Wed, 31 Mar 2021 00:06:04 +1300
Subject: [PATCH 012/111] [maven-release-plugin] prepare release
ebean-parent-12.8.1
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index ce3ba3688..d24999338 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.1
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index 5c081a9df..5897d06d5 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.1
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 665ea80be..e30fff780 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-api
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-core-type
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-ddl-generator
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-externalmapping-api
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-externalmapping-xml
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-autotune
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-querybean
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
querybean-generator
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
io.ebean
kotlin-querybean-generator
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
io.ebean
ebean-test
- 12.8.1-SNAPSHOT
+ 12.8.1
test
io.ebean
ebean-postgis
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-redis
- 12.8.1-SNAPSHOT
+ 12.8.1
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index 386d6d511..0e5b3aa23 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.8.1-SNAPSHOT
+ 12.8.1
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index e8ecd9616..da160656c 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.1
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-core-type
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-externalmapping-api
- 12.8.1-SNAPSHOT
+ 12.8.1
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 60300f7ce..7f2ea1c76 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index 4efce3a65..92440b9d6 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index cd885187e..68f5d50a4 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.1
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.8.1-SNAPSHOT
+ 12.8.1
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
test
io.ebean
ebean-ddl-generator
- 12.8.1-SNAPSHOT
+ 12.8.1
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index 5b4bceec8..dd4967ee3 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.8.1-SNAPSHOT
+ 12.8.1
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index 51f490b3b..8edf552ca 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.8.1-SNAPSHOT
+ 12.8.1
test
io.ebean
querybean-generator
- 12.8.1-SNAPSHOT
+ 12.8.1
test
io.ebean
ebean-test
- 12.8.1-SNAPSHOT
+ 12.8.1
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index 2a346b178..c258c4074 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
io.ebean
ebean-querybean
- 12.8.1-SNAPSHOT
+ 12.8.1
test
io.ebean
querybean-generator
- 12.8.1-SNAPSHOT
+ 12.8.1
test
io.ebean
ebean-test
- 12.8.1-SNAPSHOT
+ 12.8.1
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index c32dab0c2..bccddf421 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
provided
io.ebean
ebean-ddl-generator
- 12.8.1-SNAPSHOT
+ 12.8.1
diff --git a/ebean/pom.xml b/ebean/pom.xml
index 33c8aeb60..f8204d0cf 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
io.ebean
ebean-querybean
- 12.8.1-SNAPSHOT
+ 12.8.1
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 588872181..a9dda9dc6 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.8.1-SNAPSHOT
+ 12.8.1
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.8.1-SNAPSHOT
+ 12.8.1
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.8.1-SNAPSHOT
+ 12.8.1
test
diff --git a/pom.xml b/pom.xml
index 297d5ab0a..4064eef48 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.8.1-SNAPSHOT
+ 12.8.1
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.1
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index 6e7bf295f..7da5e03b1 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1-SNAPSHOT
+ 12.8.1
querybean generator
From 09d772a5e53ab99c8a0148a1704fbd1312928618 Mon Sep 17 00:00:00 2001
From: rob bygrave
Date: Wed, 31 Mar 2021 00:06:13 +1300
Subject: [PATCH 013/111] [maven-release-plugin] prepare for next development
iteration
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index d24999338..4fe1468ec 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index 5897d06d5..700861dd9 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.1
+ ebean-parent-12.8.0
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index e30fff780..401f6dbdf 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-api
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-core-type
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-ddl-generator
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-externalmapping-xml
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-autotune
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-querybean
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
querybean-generator
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
io.ebean
kotlin-querybean-generator
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
io.ebean
ebean-test
- 12.8.1
+ 12.8.2-SNAPSHOT
test
io.ebean
ebean-postgis
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-redis
- 12.8.1
+ 12.8.2-SNAPSHOT
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index 0e5b3aa23..be8b15507 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.8.1
+ 12.8.2-SNAPSHOT
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index da160656c..3652ba9a3 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.1
+ ebean-parent-12.8.0
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-core-type
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.8.1
+ 12.8.2-SNAPSHOT
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 7f2ea1c76..421166e46 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index 92440b9d6..32a98a767 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index 68f5d50a4..029f345fc 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.1
+ ebean-parent-12.8.0
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.8.1
+ 12.8.2-SNAPSHOT
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
test
io.ebean
ebean-ddl-generator
- 12.8.1
+ 12.8.2-SNAPSHOT
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index dd4967ee3..6528624f3 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.8.1
+ 12.8.2-SNAPSHOT
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index 8edf552ca..86d02f68a 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.8.1
+ 12.8.2-SNAPSHOT
test
io.ebean
querybean-generator
- 12.8.1
+ 12.8.2-SNAPSHOT
test
io.ebean
ebean-test
- 12.8.1
+ 12.8.2-SNAPSHOT
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index c258c4074..1d3a74a49 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
io.ebean
ebean-querybean
- 12.8.1
+ 12.8.2-SNAPSHOT
test
io.ebean
querybean-generator
- 12.8.1
+ 12.8.2-SNAPSHOT
test
io.ebean
ebean-test
- 12.8.1
+ 12.8.2-SNAPSHOT
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index bccddf421..65e0d345c 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
provided
io.ebean
ebean-ddl-generator
- 12.8.1
+ 12.8.2-SNAPSHOT
diff --git a/ebean/pom.xml b/ebean/pom.xml
index f8204d0cf..b293a20bc 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
io.ebean
ebean-querybean
- 12.8.1
+ 12.8.2-SNAPSHOT
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index a9dda9dc6..70432f360 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.8.1
+ 12.8.2-SNAPSHOT
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.8.1
+ 12.8.2-SNAPSHOT
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.8.1
+ 12.8.2-SNAPSHOT
test
diff --git a/pom.xml b/pom.xml
index 4064eef48..a0ce632a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.8.1
+ 12.8.2-SNAPSHOT
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.1
+ ebean-parent-12.8.0
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index 7da5e03b1..be174f512 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.1
+ 12.8.2-SNAPSHOT
querybean generator
From f9b55a06b81064e761c7abdef297f2c086c89f3e Mon Sep 17 00:00:00 2001
From: Tobias
Date: Wed, 31 Mar 2021 12:45:48 +0200
Subject: [PATCH 014/111] Add bitwise operators to query beans
---
.../java/io/ebean/typequery/PInteger.java | 66 +++++++++++++++++
.../main/java/io/ebean/typequery/PLong.java | 70 ++++++++++++++++++-
.../main/java/io/ebean/typequery/PShort.java | 68 +++++++++++++++++-
3 files changed, 201 insertions(+), 3 deletions(-)
diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PInteger.java b/ebean-querybean/src/main/java/io/ebean/typequery/PInteger.java
index 3aefa8f46..8657461be 100644
--- a/ebean-querybean/src/main/java/io/ebean/typequery/PInteger.java
+++ b/ebean-querybean/src/main/java/io/ebean/typequery/PInteger.java
@@ -24,4 +24,70 @@ public class PInteger extends PBaseNumber {
super(name, root, prefix);
}
+ /**
+ * Add bitwise AND expression of the given bit flags to compare with the match/mask.
+ *
+ *
{@code
+ *
+ * // Flags Bulk + Size = Size
+ * // ... meaning Bulk is not set and Size is set
+ *
+ * int selectedFlags = BwFlags.HAS_BULK + BwFlags.HAS_SIZE;
+ * int mask = BwFlags.HAS_SIZE; // Only Size flag set
+ *
+ * bitwiseAnd(selectedFlags, mask)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseAnd(int flags, int mask) {
+ expr().bitwiseAnd(_name, flags, mask);
+ return _root;
+ }
+
+ /**
+ * Add expression for ALL of the given bit flags to be set.
+ * {@code
+ *
+ * bitwiseAll(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseAll(int flags) {
+ expr().bitwiseAll(_name, flags);
+ return _root;
+ }
+
+ /**
+ * Add expression for ANY of the given bit flags to be set.
+ * {@code
+ *
+ * bitwiseAny(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseAny(int flags) {
+ expr().bitwiseAny(_name, flags);
+ return _root;
+ }
+
+ /**
+ * Add expression for the given bit flags to be NOT set.
+ * {@code
+ *
+ * bitwiseNot(BwFlags.HAS_COLOUR)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseNot(int flags) {
+ expr().bitwiseNot(_name, flags);
+ return _root;
+ }
}
diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PLong.java b/ebean-querybean/src/main/java/io/ebean/typequery/PLong.java
index e5869682c..d8e4cf58b 100644
--- a/ebean-querybean/src/main/java/io/ebean/typequery/PLong.java
+++ b/ebean-querybean/src/main/java/io/ebean/typequery/PLong.java
@@ -5,7 +5,7 @@ package io.ebean.typequery;
*
* @param the root query bean type
*/
-public class PLong extends PBaseNumber {
+public class PLong extends PBaseNumber {
/**
* Construct with a property name and root instance.
@@ -14,7 +14,7 @@ public class PLong extends PBaseNumber {
* @param root the root query bean instance
*/
public PLong(String name, R root) {
- super(name , root);
+ super(name, root);
}
/**
@@ -24,4 +24,70 @@ public class PLong extends PBaseNumber {
super(name, root, prefix);
}
+ /**
+ * Add bitwise AND expression of the given bit flags to compare with the match/mask.
+ *
+ *
{@code
+ *
+ * // Flags Bulk + Size = Size
+ * // ... meaning Bulk is not set and Size is set
+ *
+ * long selectedFlags = BwFlags.HAS_BULK + BwFlags.HAS_SIZE;
+ * long mask = BwFlags.HAS_SIZE; // Only Size flag set
+ *
+ * bitwiseAnd(selectedFlags, mask)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseAnd(long flags, long mask) {
+ expr().bitwiseAnd(_name, flags, mask);
+ return _root;
+ }
+
+ /**
+ * Add expression for ALL of the given bit flags to be set.
+ * {@code
+ *
+ * bitwiseAll(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseAll(long flags) {
+ expr().bitwiseAll(_name, flags);
+ return _root;
+ }
+
+ /**
+ * Add expression for ANY of the given bit flags to be set.
+ * {@code
+ *
+ * bitwiseAny(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseAny(long flags) {
+ expr().bitwiseAny(_name, flags);
+ return _root;
+ }
+
+ /**
+ * Add expression for the given bit flags to be NOT set.
+ * {@code
+ *
+ * bitwiseNot(BwFlags.HAS_COLOUR)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseNot(long flags) {
+ expr().bitwiseNot(_name, flags);
+ return _root;
+ }
}
diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PShort.java b/ebean-querybean/src/main/java/io/ebean/typequery/PShort.java
index 440a5ab4c..f8ee7bf8a 100644
--- a/ebean-querybean/src/main/java/io/ebean/typequery/PShort.java
+++ b/ebean-querybean/src/main/java/io/ebean/typequery/PShort.java
@@ -5,7 +5,7 @@ package io.ebean.typequery;
*
* @param the root query bean type
*/
-public class PShort extends PBaseNumber {
+public class PShort extends PBaseNumber {
/**
* Construct with a property name and root instance.
@@ -24,4 +24,70 @@ public class PShort extends PBaseNumber {
super(name, root, prefix);
}
+ /**
+ * Add bitwise AND expression of the given bit flags to compare with the match/mask.
+ *
+ *
{@code
+ *
+ * // Flags Bulk + Size = Size
+ * // ... meaning Bulk is not set and Size is set
+ *
+ * short selectedFlags = BwFlags.HAS_BULK + BwFlags.HAS_SIZE;
+ * short mask = BwFlags.HAS_SIZE; // Only Size flag set
+ *
+ * bitwiseAnd(selectedFlags, mask)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseAnd(short flags, short mask) {
+ expr().bitwiseAnd(_name, flags, mask);
+ return _root;
+ }
+
+ /**
+ * Add expression for ALL of the given bit flags to be set.
+ * {@code
+ *
+ * bitwiseAll(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseAll(short flags) {
+ expr().bitwiseAll(_name, flags);
+ return _root;
+ }
+
+ /**
+ * Add expression for ANY of the given bit flags to be set.
+ * {@code
+ *
+ * bitwiseAny(BwFlags.HAS_BULK + BwFlags.HAS_COLOUR)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseAny(short flags) {
+ expr().bitwiseAny(_name, flags);
+ return _root;
+ }
+
+ /**
+ * Add expression for the given bit flags to be NOT set.
+ * {@code
+ *
+ * bitwiseNot(BwFlags.HAS_COLOUR)
+ *
+ * }
+ *
+ * @param flags The flags we are looking for
+ */
+ public R bitwiseNot(short flags) {
+ expr().bitwiseNot(_name, flags);
+ return _root;
+ }
}
From f53d31aa2e80f8e05663b99daa29ee4dd8fbccdd Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Thu, 1 Apr 2021 12:22:45 +1300
Subject: [PATCH 015/111] No functional change - final field for BatchControl
---
.../main/java/io/ebeaninternal/server/persist/BatchControl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java
index 10ba7f205..f276bb331 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchControl.java
@@ -81,7 +81,7 @@ public final class BatchControl {
*/
private int bufferMax;
- private Queue[] queues = new Queue[3];
+ private final Queue[] queues = new Queue[3];
/**
* Create for a given transaction, PersistExecute, default size and getGeneratedKeys.
From a617d5890203d445cbd33badcec33ddd3d9d5c0a Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Thu, 1 Apr 2021 14:47:54 +1300
Subject: [PATCH 016/111] Initial experimental support for "transparent
persistence"
In short, when this is turned on at flush() get any dirty beans held by the PersistenceContext and persist them (always update for these beans)
---
.../src/main/java/io/ebean/Transaction.java | 8 +
.../io/ebean/bean/PersistenceContext.java | 7 +
.../ebeaninternal/api/ScopedTransaction.java | 5 +
.../server/core/DefaultServer.java | 2 +-
.../server/core/InternalConfiguration.java | 4 +-
.../DefaultPersistenceContext.java | 31 ++-
.../ImplicitReadOnlyTransaction.java | 5 +
.../server/transaction/JdbcTransaction.java | 14 +-
.../server/transaction/NoTransaction.java | 5 +
.../transaction/SavepointTransaction.java | 5 +
.../transaction/TransactionManager.java | 16 +-
.../TransactionManagerOptions.java | 6 +-
.../TestTransparentPersist.java | 204 ++++++++++++++++++
.../src/test/resources/logback-test.xml | 4 +-
14 files changed, 303 insertions(+), 13 deletions(-)
create mode 100644 ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
diff --git a/ebean-api/src/main/java/io/ebean/Transaction.java b/ebean-api/src/main/java/io/ebean/Transaction.java
index d4918e84e..0cbfd6e3c 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 transparent persistence and batchMode true.
+ *
+ * With this turned on beans that are dirty in the persistence context
+ * are automatically persisted on flush() and commit().
+ */
+ void setTransparentPersistence(boolean transparentPersistence);
+
/**
* Set a label on the transaction.
*
diff --git a/ebean-api/src/main/java/io/ebean/bean/PersistenceContext.java b/ebean-api/src/main/java/io/ebean/bean/PersistenceContext.java
index a8a42e51b..8c861af1f 100644
--- a/ebean-api/src/main/java/io/ebean/bean/PersistenceContext.java
+++ b/ebean-api/src/main/java/io/ebean/bean/PersistenceContext.java
@@ -1,5 +1,7 @@
package io.ebean.bean;
+import java.util.List;
+
/**
* Holds entity beans by there type and id.
*
@@ -77,6 +79,11 @@ public interface PersistenceContext {
*/
boolean resetLimit();
+ /**
+ * Return the list of dirty beans held by this persistence context.
+ */
+ List dirtyBeans();
+
/**
* Wrapper on a bean to also indicate if a bean has been deleted.
*
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java
index f5a1db07b..6e95a114e 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java
@@ -131,6 +131,11 @@ public class ScopedTransaction extends SpiTransactionProxy {
}
}
+ @Override
+ public void setTransparentPersistence(boolean transparentPersistence) {
+ current.getTransaction().setTransparentPersistence(transparentPersistence);
+ }
+
@Override
public void setRollbackOnly() {
current.setRollbackOnly();
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
index 52b94bfb6..6595d9816 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java
@@ -236,7 +236,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
this.clockService = config.getClockService();
DocStoreIntegration docStoreComponents = config.createDocStoreIntegration(this);
- this.transactionManager = config.createTransactionManager(docStoreComponents.updateProcessor());
+ this.transactionManager = config.createTransactionManager(this, docStoreComponents.updateProcessor());
this.documentStore = docStoreComponents.documentStore();
this.queryPlanManager = config.initQueryPlanManager(transactionManager);
this.metaInfoManager = new DefaultMetaInfoManager(this);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
index 8cbbbfa4b..dca8e3059 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/InternalConfiguration.java
@@ -423,13 +423,13 @@ public class InternalConfiguration {
/**
* Create the TransactionManager taking into account autoCommit mode.
*/
- TransactionManager createTransactionManager(DocStoreUpdateProcessor indexUpdateProcessor) {
+ TransactionManager createTransactionManager(SpiServer server, DocStoreUpdateProcessor indexUpdateProcessor) {
TransactionScopeManager scopeManager = createTransactionScopeManager();
boolean notifyL2CacheInForeground = cacheManager.isLocalL2Caching() || config.isNotifyL2CacheInForeground();
TransactionManagerOptions options =
- new TransactionManagerOptions(notifyL2CacheInForeground, config, scopeManager, clusterManager, backgroundExecutor,
+ new TransactionManagerOptions(server, notifyL2CacheInForeground, config, scopeManager, clusterManager, backgroundExecutor,
indexUpdateProcessor, beanDescriptorManager, dataSource(), profileHandler(), logManager,
tableModState, cacheNotify, clockService);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java
index df92246fa..27eea2e4c 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/DefaultPersistenceContext.java
@@ -1,11 +1,9 @@
package io.ebeaninternal.server.transaction;
+import io.ebean.bean.EntityBean;
import io.ebean.bean.PersistenceContext;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
/**
@@ -200,6 +198,20 @@ public final class DefaultPersistenceContext implements PersistenceContext {
}
}
+ @Override
+ public List dirtyBeans() {
+ lock.lock();
+ try {
+ List list = new ArrayList<>();
+ for (ClassContext classContext : typeCache.values()) {
+ classContext.dirtyBeans(list);
+ }
+ return list;
+ } finally {
+ lock.unlock();
+ }
+ }
+
@Override
public String toString() {
lock.lock();
@@ -318,6 +330,17 @@ public final class DefaultPersistenceContext implements PersistenceContext {
deleteSet.add(id);
map.remove(id);
}
+
+ /**
+ * Add the dirty beans to the list.
+ */
+ void dirtyBeans(List list) {
+ for (Object value : map.values()) {
+ if (((EntityBean) value)._ebean_getIntercept().isDirty()) {
+ list.add(value);
+ }
+ }
+ }
}
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java
index 79bf85335..04d7a83a5 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java
@@ -95,6 +95,11 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
return startNanos;
}
+ @Override
+ public void setTransparentPersistence(boolean transparentPersistence) {
+ // do nothing
+ }
+
@Override
public void setLabel(String label) {
// do nothing
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
index 8c1897ff5..2585c2b23 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
@@ -187,6 +187,8 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
private final long startNanos;
+ private boolean transparentPersistence;
+
/**
* Create a new JdbcTransaction.
*/
@@ -294,6 +296,12 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
return sb.toString();
}
+ @Override
+ public void setTransparentPersistence(boolean transparentPersistence) {
+ this.transparentPersistence = transparentPersistence;
+ this.batchMode = true;
+ }
+
@Override
public boolean isSkipCacheExplicit() {
return (skipCache != null && !skipCache);
@@ -774,6 +782,10 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
* Flush the JDBC batch and execute derived relationship statements if necessary.
*/
private void internalBatchFlush() {
+ if (transparentPersistence) {
+ // Experimental - flush dirty beans held by the persistence context
+ manager.flushTransparent(persistenceContext, this);
+ }
batchFlush();
if (deferredList != null) {
for (PersistDeferredRelationship deferred : deferredList) {
@@ -1042,7 +1054,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
throw new IllegalStateException(illegalStateMessage);
}
try {
- if (queryOnly) {
+ if (queryOnly && !transparentPersistence) {
connectionEndForQueryOnly();
} else {
flushCommitAndNotify();
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java
index 2ef3f2058..5d593302f 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java
@@ -25,6 +25,11 @@ class NoTransaction implements SpiTransaction {
static final NoTransaction INSTANCE = new NoTransaction();
+ @Override
+ public void setTransparentPersistence(boolean transparentPersistence) {
+ // do nothing
+ }
+
@Override
public void setLabel(String label) {
// do nothing
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java
index b50122f5c..7b596afec 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java
@@ -60,6 +60,11 @@ class SavepointTransaction extends SpiTransactionProxy {
this.rollbackOnly = true;
}
+ @Override
+ public void setTransparentPersistence(boolean transparentPersistence) {
+ throw new IllegalStateException("This is not handled yet. Need to review this case.");
+ }
+
@Override
public void commit() {
if (rollbackOnly) {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java
index e42ce2fe3..45885ad2a 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java
@@ -5,6 +5,7 @@ import io.ebean.ProfileLocation;
import io.ebean.TxScope;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.TxType;
+import io.ebean.bean.PersistenceContext;
import io.ebean.cache.ServerCacheNotification;
import io.ebean.cache.ServerCacheNotify;
import io.ebean.config.CurrentTenantProvider;
@@ -17,6 +18,7 @@ import io.ebean.meta.MetricVisitor;
import io.ebean.metric.MetricFactory;
import io.ebean.metric.TimedMetric;
import io.ebean.metric.TimedMetricMap;
+import io.ebean.plugin.SpiServer;
import io.ebeaninternal.api.ScopeTrans;
import io.ebeaninternal.api.ScopedTransaction;
import io.ebeaninternal.api.SpiLogManager;
@@ -59,6 +61,8 @@ public class TransactionManager implements SpiTransactionManager {
private static final Logger clusterLogger = LoggerFactory.getLogger("io.ebean.Cluster");
+ private final SpiServer server;
+
private final BeanDescriptorManager beanDescriptorManager;
/**
@@ -153,7 +157,7 @@ public class TransactionManager implements SpiTransactionManager {
* Create the TransactionManager
*/
public TransactionManager(TransactionManagerOptions options) {
-
+ this.server = options.server;
this.logManager = options.logManager;
this.txnLogger = logManager.txn();
this.txnDebug = txnLogger.isDebug();
@@ -786,4 +790,14 @@ public class TransactionManager implements SpiTransactionManager {
public boolean isLogSummary() {
return logManager.sum().isDebug();
}
+
+ /**
+ * Experimental - find dirty beans in the persistence context and persist them.
+ */
+ public void flushTransparent(PersistenceContext persistenceContext, SpiTransaction transaction) {
+ List dirtyBeans = persistenceContext.dirtyBeans();
+ if (!dirtyBeans.isEmpty()) {
+ server.updateAll(dirtyBeans, transaction);
+ }
+ }
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java
index 9a1b0139b..5d0c87794 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManagerOptions.java
@@ -3,6 +3,7 @@ package io.ebeaninternal.server.transaction;
import io.ebean.BackgroundExecutor;
import io.ebean.cache.ServerCacheNotify;
import io.ebean.config.DatabaseConfig;
+import io.ebean.plugin.SpiServer;
import io.ebeaninternal.api.SpiLogManager;
import io.ebeaninternal.api.SpiProfileHandler;
import io.ebeaninternal.server.cluster.ClusterManager;
@@ -15,6 +16,7 @@ import io.ebeanservice.docstore.api.DocStoreUpdateProcessor;
*/
public class TransactionManagerOptions {
+ final SpiServer server;
final boolean notifyL2CacheInForeground;
final DatabaseConfig config;
final ClusterManager clusterManager;
@@ -31,11 +33,11 @@ public class TransactionManagerOptions {
final ClockService clockService;
- public TransactionManagerOptions(boolean notifyL2CacheInForeground, DatabaseConfig config, TransactionScopeManager scopeManager, ClusterManager clusterManager,
+ public TransactionManagerOptions(SpiServer server, boolean notifyL2CacheInForeground, DatabaseConfig config, TransactionScopeManager scopeManager, ClusterManager clusterManager,
BackgroundExecutor backgroundExecutor, DocStoreUpdateProcessor docStoreUpdateProcessor,
BeanDescriptorManager descMgr, DataSourceSupplier dataSourceSupplier, SpiProfileHandler profileHandler,
SpiLogManager logManager, TableModState tableModState, ServerCacheNotify cacheNotify, ClockService clockService) {
-
+ this.server = server;
this.notifyL2CacheInForeground = notifyL2CacheInForeground;
this.config = config;
this.scopeManager = scopeManager;
diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
new file mode 100644
index 000000000..2922d20b2
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
@@ -0,0 +1,204 @@
+package org.tests.transparentpersist;
+
+import io.ebean.BaseTestCase;
+import io.ebean.DB;
+import io.ebean.Database;
+import io.ebean.Transaction;
+import io.ebeaninternal.api.SpiTransaction;
+import io.ebeantest.LoggedSql;
+import org.junit.Test;
+import org.tests.model.basic.Customer;
+import org.tests.model.basic.EBasicVer;
+import org.tests.model.basic.Order;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class TestTransparentPersist extends BaseTestCase {
+
+ @Test
+ public void simpleInsertUpdateDelete_experimental() {
+
+ EBasicVer b0 = new EBasicVer("simpleIUD_0");
+ b0.save();
+ EBasicVer b1 = new EBasicVer("simpleIUD_1");
+ b1.save();
+ EBasicVer b2 = new EBasicVer("simpleIUD_2");
+ b2.save();
+
+ EBasicVer newBean;
+ try (Transaction transaction = DB.beginTransaction()) {
+ transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+
+ EBasicVer found = DB.find(EBasicVer.class, b0.getId());
+ found.setName("auto dirty");
+
+ // delete by id
+ DB.delete(EBasicVer.class, b1.getId());
+ // find and delete, note the delete is batched up to execute later
+ DB.delete(DB.find(EBasicVer.class, b2.getId()));
+
+ // insert is batched up to execute later
+ newBean = new EBasicVer("simpleIUD_New1");
+ DB.save(newBean);
+ // can still mutate newBean before flush (but not after flush yet as new bean isn't put into Persistence context)
+ newBean.setName("simpleIUD_New2");
+
+ transaction.commit();
+ }
+
+ EBasicVer after = DB.find(EBasicVer.class, b0.getId());
+ assertThat(after.getName()).isEqualTo("auto dirty");
+
+ EBasicVer wasInserted = DB.find(EBasicVer.class, newBean.getId());
+ assertThat(wasInserted.getName()).isEqualTo("simpleIUD_New2");
+
+ assertThat(DB.find(EBasicVer.class, b1.getId())).isNull();
+ assertThat(DB.find(EBasicVer.class, b2.getId())).isNull();
+
+ DB.delete(after);
+ DB.delete(wasInserted);
+ }
+
+ @Test
+ public void simpleUpdate_experimental() {
+
+ EBasicVer transPersist = new EBasicVer("simulate_simpleUpdate");
+ transPersist.save();
+
+ try (Transaction transaction = DB.beginTransaction()) {
+ transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+
+ EBasicVer found = DB.find(EBasicVer.class, transPersist.getId());
+ found.setName("Persisted automatically as dirty");
+
+ transaction.commit();
+ }
+
+ EBasicVer after = DB.find(EBasicVer.class,transPersist.getId());
+ assertThat(after.getName()).isEqualTo("Persisted automatically as dirty");
+ DB.delete(after);
+ }
+
+ @Test
+ public void updateWithPersistCascadeInsert() {
+
+ // setup data
+ Customer c0 = new Customer();
+ c0.setName("firstCust");
+ Order order = new Order();
+ order.setStatus(Order.Status.NEW);
+ order.setCustomer(c0);
+ DB.save(order);
+
+ try (Transaction transaction = DB.beginTransaction()) {
+ transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+
+ Order foundOrder = DB.find(Order.class, order.getId());
+ foundOrder.setStatus(Order.Status.APPROVED);
+ // cascade persist will insert this customer (even though it isn't in the persistence context)
+ Customer c1 = new Customer();
+ c1.setName("newCust CascadePersist");
+ foundOrder.setCustomer(c1);
+
+ transaction.commit();
+ }
+
+ Order checkOrder = DB.find(Order.class, order.getId());
+
+ assertThat(checkOrder.getStatus()).isEqualTo(Order.Status.APPROVED);
+ assertThat(checkOrder.getCustomer().getName()).isEqualTo("newCust CascadePersist");
+
+ DB.delete(checkOrder);
+ DB.delete(Customer.class, checkOrder.getCustomer().getId());
+ DB.delete(Customer.class, c0.getId());
+ }
+
+ @Test
+ public void updateReferenceOnlyWithPersistCascade_Insert_andUpdateForeignKey() {
+
+ // setup data
+ Customer c0 = new Customer();
+ c0.setName("firstCust");
+ Order order = new Order();
+ order.setStatus(Order.Status.NEW);
+ order.setCustomer(c0);
+ DB.save(order);
+
+ LoggedSql.start();
+
+ try (Transaction transaction = DB.beginTransaction()) {
+ transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+
+ Order foundOrder = DB.find(Order.class, order.getId());
+ // we ONLY mutate the foreign key
+ // cascade persist will insert this customer (even though it isn't in the persistence context)
+ Customer c1 = new Customer();
+ c1.setName("newCust CascadePersist");
+ foundOrder.setCustomer(c1);
+
+ transaction.commit();
+ }
+
+ List sql = LoggedSql.stop();
+
+ Order checkOrder = DB.find(Order.class, order.getId());
+
+ assertThat(checkOrder.getStatus()).isEqualTo(Order.Status.NEW);
+ assertThat(checkOrder.getCustomer().getName()).isEqualTo("newCust CascadePersist");
+
+ assertThat(sql).hasSize(5);
+ assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.order_date");
+ assertThat(sql.get(1)).contains("insert into o_customer");
+ assertThat(sql.get(2)).contains(" -- bind(");
+ assertThat(sql.get(3)).contains("update o_order set updtime=?, kcustomer_id=? where id=? and updtime=?");
+ assertThat(sql.get(4)).contains(" -- bind(");
+
+ DB.delete(checkOrder);
+ DB.delete(Customer.class, checkOrder.getCustomer().getId());
+ DB.delete(Customer.class, c0.getId());
+ }
+
+ @Test
+ public void simulate_transparentPersistence_forSimpleUpdate() {
+
+ EBasicVer transPersist = new EBasicVer("simulate_simpleUpdate");
+ transPersist.save();
+
+ try (Transaction transaction = DB.beginTransaction()) {
+ transaction.setBatchMode(true);
+ transaction.setBatchSize(10);
+
+ EBasicVer found = DB.find(EBasicVer.class, transPersist.getId());
+ found.setName("Changed");
+
+ // simulate transparent persistence
+ List dirtyBeans = simulateTransparentPersist(transaction);
+ assertThat(dirtyBeans).hasSize(1);
+ assertThat(dirtyBeans).contains(found);
+
+ // would occur as first part of flush
+ transaction.flush();
+ transaction.commit();
+ }
+
+ EBasicVer after = DB.find(EBasicVer.class,transPersist.getId());
+ assertThat(after.getName()).isEqualTo("Changed");
+ DB.delete(after);
+ }
+
+ private List simulateTransparentPersist(Transaction transaction) {
+ Database db = DB.getDefault();
+ List dirtyBeans = getDirtyBeansFromPersistenceContext(transaction);
+ for (Object dirtyBean : dirtyBeans) {
+ db.update(dirtyBean, transaction);
+ }
+ return dirtyBeans;
+ }
+
+ private List getDirtyBeansFromPersistenceContext(Transaction transaction) {
+ return ((SpiTransaction)transaction).getPersistenceContext().dirtyBeans();
+ }
+
+}
diff --git a/ebean-core/src/test/resources/logback-test.xml b/ebean-core/src/test/resources/logback-test.xml
index 1b8a60a9b..164ff73d3 100644
--- a/ebean-core/src/test/resources/logback-test.xml
+++ b/ebean-core/src/test/resources/logback-test.xml
@@ -79,8 +79,8 @@
-
-
+
+
From ba397bbb0c383bb9be0d1174e3752b9db09c4ef5 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Thu, 1 Apr 2021 16:04:18 +1300
Subject: [PATCH 017/111] For experimental "transparent persistence" - Delete
removes from PC early
When delete bean executed with transparent persistence, this marks the bean as removed from the persistence context early.
This avoids a "dirty" deleted bean from being seen as a "dirty" bean in the persistence context at flush() time.
---
.../server/core/PersistRequestBean.java | 8 +++++++
.../server/persist/DefaultPersister.java | 1 +
.../TestTransparentPersist.java | 23 +++++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
index eb48fc2ef..c4d02cbf6 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
@@ -887,6 +887,14 @@ public final class PersistRequestBean extends PersistRequest implements BeanP
}
}
+ /**
+ * Remove deleted beans from the persistence context early.
+ */
+ public void removeFromPersistenceContext() {
+ idValue = beanDescriptor.getId(entityBean);
+ beanDescriptor.contextDeleted(transaction.getPersistenceContext(), idValue);
+ }
+
/**
* Aggressive L1 and L2 cache cleanup for deletes.
*/
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
index a7b21f0c8..005e85d95 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
@@ -881,6 +881,7 @@ public final class DefaultPersister implements Persister {
}
int count = request.executeOrQueue();
+ request.removeFromPersistenceContext();
if (request.isPersistCascade()) {
deleteAssocOne(request);
diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
index 2922d20b2..be5d8329b 100644
--- a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
+++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
@@ -17,6 +17,29 @@ import static org.assertj.core.api.Assertions.assertThat;
public class TestTransparentPersist extends BaseTestCase {
+ @Test
+ public void delete_expect_beanRemovedFromPersistenceContext() {
+
+ EBasicVer b0 = new EBasicVer("simpleDelete");
+ DB.save(b0);
+
+ try (Transaction transaction = DB.beginTransaction()) {
+ transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+
+ EBasicVer found = DB.find(EBasicVer.class, b0.getId());
+ // make it dirty
+ found.setName("make it dirty");
+
+ // delete it, should remove it from the "live" part of persistence context
+ // with the expectation that no update is executed (no dirty in PC update)
+ DB.delete(found);
+ transaction.commit();
+ }
+
+ EBasicVer after = DB.find(EBasicVer.class, b0.getId());
+ assertThat(after).isNull();
+ }
+
@Test
public void simpleInsertUpdateDelete_experimental() {
From 0527f45f5a4e3b479296e051493cf536728bcc06 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Thu, 1 Apr 2021 16:59:03 +1300
Subject: [PATCH 018/111] For experimental "transparent persistence" - Inserts
added to PC
When inserting bean with transparent persistence the beans are registered with the persistence context. This is done to support the cases where the beans are inserted, a flush() occurs, the inserted bean is mutated and now dirty - we want that to be detected and get an update
---
.../ebeaninternal/api/ScopedTransaction.java | 5 ---
.../io/ebeaninternal/api/SpiTransaction.java | 5 +++
.../api/SpiTransactionProxy.java | 10 ++++++
.../server/core/PersistRequestBean.java | 4 +++
.../ImplicitReadOnlyTransaction.java | 5 +++
.../server/transaction/JdbcTransaction.java | 5 +++
.../server/transaction/NoTransaction.java | 5 +++
.../transaction/SavepointTransaction.java | 5 ---
.../TestTransparentPersist.java | 36 +++++++++++++++++++
9 files changed, 70 insertions(+), 10 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java
index 6e95a114e..f5a1db07b 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/ScopedTransaction.java
@@ -131,11 +131,6 @@ public class ScopedTransaction extends SpiTransactionProxy {
}
}
- @Override
- public void setTransparentPersistence(boolean transparentPersistence) {
- current.getTransaction().setTransparentPersistence(transparentPersistence);
- }
-
@Override
public void setRollbackOnly() {
current.setRollbackOnly();
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java
index 74faeccb0..8c520f79e 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java
@@ -147,6 +147,11 @@ public interface SpiTransaction extends Transaction {
*/
int depth();
+ /**
+ * Return true if transparent persistence is turned on.
+ */
+ boolean isTransparentPersistence();
+
/**
* Return true if this transaction was created explicitly via
* Ebean.beginTransaction().
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java
index fe5351ddc..1652b56f6 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java
@@ -43,6 +43,16 @@ public abstract class SpiTransactionProxy implements SpiTransaction {
return transaction.getLabel();
}
+ @Override
+ public void setTransparentPersistence(boolean transparentPersistence) {
+ transaction.setTransparentPersistence(transparentPersistence);
+ }
+
+ @Override
+ public boolean isTransparentPersistence() {
+ return transaction.isTransparentPersistence();
+ }
+
@Override
public void commitAndContinue() {
transaction.commitAndContinue();
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
index c4d02cbf6..3f7d6e79a 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
@@ -1038,6 +1038,10 @@ public final class PersistRequestBean extends PersistRequest implements BeanP
if (!publish) {
beanDescriptor.setDraft(entityBean);
}
+ if (transaction.isTransparentPersistence() && idValue != null) {
+ // with getGeneratedKeys off we will not have a idValue
+ beanDescriptor.contextPut(transaction.getPersistenceContext(), idValue, entityBean);
+ }
}
public boolean isReference() {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java
index 04d7a83a5..a94260fb6 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java
@@ -100,6 +100,11 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
// do nothing
}
+ @Override
+ public boolean isTransparentPersistence() {
+ return false;
+ }
+
@Override
public void setLabel(String label) {
// do nothing
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
index 2585c2b23..bb672cd33 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
@@ -302,6 +302,11 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
this.batchMode = true;
}
+ @Override
+ public boolean isTransparentPersistence() {
+ return transparentPersistence;
+ }
+
@Override
public boolean isSkipCacheExplicit() {
return (skipCache != null && !skipCache);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java
index 5d593302f..92f0e1ca9 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java
@@ -30,6 +30,11 @@ class NoTransaction implements SpiTransaction {
// do nothing
}
+ @Override
+ public boolean isTransparentPersistence() {
+ return false;
+ }
+
@Override
public void setLabel(String label) {
// do nothing
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java
index 7b596afec..b50122f5c 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/SavepointTransaction.java
@@ -60,11 +60,6 @@ class SavepointTransaction extends SpiTransactionProxy {
this.rollbackOnly = true;
}
- @Override
- public void setTransparentPersistence(boolean transparentPersistence) {
- throw new IllegalStateException("This is not handled yet. Need to review this case.");
- }
-
@Override
public void commit() {
if (rollbackOnly) {
diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
index be5d8329b..a59ddda60 100644
--- a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
+++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
@@ -17,6 +17,42 @@ import static org.assertj.core.api.Assertions.assertThat;
public class TestTransparentPersist extends BaseTestCase {
+ @Test
+ public void insertFlush_mutateFlush_expect_update() {
+
+ LoggedSql.start();
+
+ EBasicVer newBean;
+ try (Transaction transaction = DB.beginTransaction()) {
+ transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+
+ newBean = new EBasicVer("insertMe");
+ DB.save(newBean);
+
+ // flush - new bean needs to get registered into persistence context
+ transaction.flush();
+
+ // make it dirty, we expect it to execute an update on flush()
+ newBean.setName("make it dirty - auto save");
+
+ // flush again, auto persist dirty bean in persistence context
+ transaction.commit();
+ }
+
+ List sql = LoggedSql.stop();
+
+ EBasicVer found = DB.find(EBasicVer.class, newBean.getId());
+ assertThat(found.getName()).isEqualTo("make it dirty - auto save");
+
+ assertThat(sql).hasSize(4);
+ assertThat(sql.get(0)).contains("insert into e_basicver");
+ assertThat(sql.get(1)).contains(" -- bind(");
+ assertThat(sql.get(2)).contains("update e_basicver set name=?, last_update=? where id=? and last_update=?");
+ assertThat(sql.get(3)).contains(" -- bind(");
+
+ DB.delete(found);
+ }
+
@Test
public void delete_expect_beanRemovedFromPersistenceContext() {
From 6bcf5c6881e14b0156abaaf14fd4cff39dce8df1 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Thu, 1 Apr 2021 22:57:34 +1300
Subject: [PATCH 019/111] Add DatabaseConfig.autoPersistUpdates for
experimental "transparent persistence"
---
.../java/io/ebean/config/DatabaseConfig.java | 23 ++++++++++++++++++-
.../server/transaction/JdbcTransaction.java | 5 ++--
.../transaction/TransactionManager.java | 11 +++++++--
.../io/ebean/config/ServerConfigTest.java | 3 +++
4 files changed, 37 insertions(+), 5 deletions(-)
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 bf4c61675..be2ac6c1f 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
@@ -232,6 +232,12 @@ public class DatabaseConfig {
*/
private String historyTableSuffix = "_history";
+ /**
+ * When true explicit transactions beans that have been made dirty will be
+ * automatically persisted via update on flush.
+ */
+ private boolean autoPersistUpdates;
+
/**
* Use for transaction scoped batch mode.
*/
@@ -905,6 +911,20 @@ public class DatabaseConfig {
this.tenantCatalogProvider = tenantCatalogProvider;
}
+ /**
+ * Return true if dirty beans are automatically persisted.
+ */
+ public boolean isAutoPersistUpdates() {
+ return autoPersistUpdates;
+ }
+
+ /**
+ * Set to true if dirty beans are automatically persisted.
+ */
+ public void setAutoPersistUpdates(boolean autoPersistUpdates) {
+ this.autoPersistUpdates = autoPersistUpdates;
+ }
+
/**
* Return the PersistBatch mode to use by default at the transaction level.
*
@@ -2807,6 +2827,7 @@ public class DatabaseConfig {
loadDocStoreSettings(p);
defaultServer = p.getBoolean("defaultServer", defaultServer);
+ autoPersistUpdates = p.getBoolean("autoPersistUpdates", autoPersistUpdates);
loadModuleInfo = p.getBoolean("loadModuleInfo", loadModuleInfo);
maxCallStack = p.getInt("maxCallStack", maxCallStack);
dumpMetricsOnShutdown = p.getBoolean("dumpMetricsOnShutdown", dumpMetricsOnShutdown);
@@ -3348,7 +3369,7 @@ public class DatabaseConfig {
this.loadModuleInfo = loadModuleInfo;
}
- public enum UuidVersion {
+ public enum UuidVersion {
VERSION4,
VERSION1,
VERSION1RND
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
index bb672cd33..411331aef 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
@@ -211,11 +211,12 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
this.batchOnCascadeMode = false;
this.onQueryOnly = OnQueryOnly.ROLLBACK;
} else {
+ this.transparentPersistence = explicit && manager.isAutoPersistUpdates();
this.logSql = manager.isLogSql();
this.logSummary = manager.isLogSummary();
this.skipCacheAfterWrite = manager.isSkipCacheAfterWrite();
- this.batchMode = manager.getPersistBatch();
- this.batchOnCascadeMode = manager.getPersistBatchOnCascade();
+ this.batchMode = manager.isPersistBatch();
+ this.batchOnCascadeMode = manager.isPersistBatchOnCascade();
this.onQueryOnly = manager.getOnQueryOnly();
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java
index 45885ad2a..b71868e5d 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java
@@ -104,6 +104,8 @@ public class TransactionManager implements SpiTransactionManager {
*/
final DocStoreUpdateProcessor docStoreUpdateProcessor;
+ private final boolean autoPersistUpdates;
+
private final boolean persistBatch;
private final boolean persistBatchOnCascade;
@@ -165,6 +167,7 @@ public class TransactionManager implements SpiTransactionManager {
this.supportsSavepointId = databasePlatform.isSupportsSavepointId();
this.skipCacheAfterWrite = options.config.isSkipCacheAfterWrite();
this.notifyL2CacheInForeground = options.notifyL2CacheInForeground;
+ this.autoPersistUpdates = options.config.isAutoPersistUpdates();
this.persistBatch = PersistBatch.ALL == options.config.getPersistBatch();
this.persistBatchOnCascade = PersistBatch.ALL == options.config.appliedPersistBatchOnCascade();
this.rollbackOnChecked = options.config.isTransactionRollbackOnChecked();
@@ -283,11 +286,15 @@ public class TransactionManager implements SpiTransactionManager {
return bulkEventListenerMap;
}
- boolean getPersistBatch() {
+ boolean isAutoPersistUpdates() {
+ return autoPersistUpdates;
+ }
+
+ boolean isPersistBatch() {
return persistBatch;
}
- public boolean getPersistBatchOnCascade() {
+ boolean isPersistBatchOnCascade() {
return persistBatchOnCascade;
}
diff --git a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
index f93c18d26..4e92798d6 100644
--- a/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
+++ b/ebean-core/src/test/java/io/ebean/config/ServerConfigTest.java
@@ -149,6 +149,7 @@ public class ServerConfigTest {
ServerConfig serverConfig = new ServerConfig();
assertTrue(serverConfig.isIdGeneratorAutomatic());
assertTrue(serverConfig.isDefaultServer());
+ assertFalse(serverConfig.isAutoPersistUpdates());
serverConfig.setIdGeneratorAutomatic(false);
assertFalse(serverConfig.isIdGeneratorAutomatic());
@@ -166,6 +167,8 @@ public class ServerConfigTest {
serverConfig.setLoadModuleInfo(false);
assertFalse(serverConfig.isAutoLoadModuleInfo());
+ serverConfig.setAutoPersistUpdates(true);
+ assertTrue(serverConfig.isAutoPersistUpdates());
}
@Test
From 303039735f1cbae070cced68706a64b2dddb3bc8 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Thu, 1 Apr 2021 23:04:22 +1300
Subject: [PATCH 020/111] Refactor rename transparentPersistence to
autoPersistUpdates
---
.../src/main/java/io/ebean/Transaction.java | 4 ++--
.../io/ebeaninternal/api/SpiTransaction.java | 4 ++--
.../ebeaninternal/api/SpiTransactionProxy.java | 8 ++++----
.../server/core/PersistRequestBean.java | 2 +-
.../transaction/ImplicitReadOnlyTransaction.java | 4 ++--
.../server/transaction/JdbcTransaction.java | 16 ++++++++--------
.../server/transaction/NoTransaction.java | 4 ++--
.../TestTransparentPersist.java | 12 ++++++------
8 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/ebean-api/src/main/java/io/ebean/Transaction.java b/ebean-api/src/main/java/io/ebean/Transaction.java
index 0cbfd6e3c..9a391d654 100644
--- a/ebean-api/src/main/java/io/ebean/Transaction.java
+++ b/ebean-api/src/main/java/io/ebean/Transaction.java
@@ -60,12 +60,12 @@ public interface Transaction extends AutoCloseable {
void register(TransactionCallback callback);
/**
- * EXPERIMENTAL - turn on transparent persistence and batchMode true.
+ * 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 setTransparentPersistence(boolean transparentPersistence);
+ void setAutoPersistUpdates(boolean autoPersistUpdates);
/**
* Set a label on the transaction.
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java
index 8c520f79e..8c59fa7dc 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransaction.java
@@ -148,9 +148,9 @@ public interface SpiTransaction extends Transaction {
int depth();
/**
- * Return true if transparent persistence is turned on.
+ * Return true if dirty beans are automatically persisted.
*/
- boolean isTransparentPersistence();
+ boolean isAutoPersistUpdates();
/**
* Return true if this transaction was created explicitly via
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java
index 1652b56f6..5fd2a3c6e 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiTransactionProxy.java
@@ -44,13 +44,13 @@ public abstract class SpiTransactionProxy implements SpiTransaction {
}
@Override
- public void setTransparentPersistence(boolean transparentPersistence) {
- transaction.setTransparentPersistence(transparentPersistence);
+ public void setAutoPersistUpdates(boolean autoPersistUpdates) {
+ transaction.setAutoPersistUpdates(autoPersistUpdates);
}
@Override
- public boolean isTransparentPersistence() {
- return transaction.isTransparentPersistence();
+ public boolean isAutoPersistUpdates() {
+ return transaction.isAutoPersistUpdates();
}
@Override
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
index 3f7d6e79a..31d92b0a0 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
@@ -1038,7 +1038,7 @@ public final class PersistRequestBean extends PersistRequest implements BeanP
if (!publish) {
beanDescriptor.setDraft(entityBean);
}
- if (transaction.isTransparentPersistence() && idValue != null) {
+ if (transaction.isAutoPersistUpdates() && idValue != null) {
// with getGeneratedKeys off we will not have a idValue
beanDescriptor.contextPut(transaction.getPersistenceContext(), idValue, entityBean);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java
index a94260fb6..5f2b5d195 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/ImplicitReadOnlyTransaction.java
@@ -96,12 +96,12 @@ class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEventCode
}
@Override
- public void setTransparentPersistence(boolean transparentPersistence) {
+ public void setAutoPersistUpdates(boolean autoPersistUpdates) {
// do nothing
}
@Override
- public boolean isTransparentPersistence() {
+ public boolean isAutoPersistUpdates() {
return false;
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
index 411331aef..7d3b3ddf1 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java
@@ -187,7 +187,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
private final long startNanos;
- private boolean transparentPersistence;
+ private boolean autoPersistUpdates;
/**
* Create a new JdbcTransaction.
@@ -211,7 +211,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
this.batchOnCascadeMode = false;
this.onQueryOnly = OnQueryOnly.ROLLBACK;
} else {
- this.transparentPersistence = explicit && manager.isAutoPersistUpdates();
+ this.autoPersistUpdates = explicit && manager.isAutoPersistUpdates();
this.logSql = manager.isLogSql();
this.logSummary = manager.isLogSummary();
this.skipCacheAfterWrite = manager.isSkipCacheAfterWrite();
@@ -298,14 +298,14 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
}
@Override
- public void setTransparentPersistence(boolean transparentPersistence) {
- this.transparentPersistence = transparentPersistence;
+ public void setAutoPersistUpdates(boolean autoPersistUpdates) {
+ this.autoPersistUpdates = autoPersistUpdates;
this.batchMode = true;
}
@Override
- public boolean isTransparentPersistence() {
- return transparentPersistence;
+ public boolean isAutoPersistUpdates() {
+ return autoPersistUpdates;
}
@Override
@@ -788,7 +788,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
* Flush the JDBC batch and execute derived relationship statements if necessary.
*/
private void internalBatchFlush() {
- if (transparentPersistence) {
+ if (autoPersistUpdates) {
// Experimental - flush dirty beans held by the persistence context
manager.flushTransparent(persistenceContext, this);
}
@@ -1060,7 +1060,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
throw new IllegalStateException(illegalStateMessage);
}
try {
- if (queryOnly && !transparentPersistence) {
+ if (queryOnly && !autoPersistUpdates) {
connectionEndForQueryOnly();
} else {
flushCommitAndNotify();
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java
index 92f0e1ca9..0d3c82cd6 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/NoTransaction.java
@@ -26,12 +26,12 @@ class NoTransaction implements SpiTransaction {
static final NoTransaction INSTANCE = new NoTransaction();
@Override
- public void setTransparentPersistence(boolean transparentPersistence) {
+ public void setAutoPersistUpdates(boolean autoPersistUpdates) {
// do nothing
}
@Override
- public boolean isTransparentPersistence() {
+ public boolean isAutoPersistUpdates() {
return false;
}
diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
index a59ddda60..963cc1dcb 100644
--- a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
+++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
@@ -24,7 +24,7 @@ public class TestTransparentPersist extends BaseTestCase {
EBasicVer newBean;
try (Transaction transaction = DB.beginTransaction()) {
- transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+ transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
newBean = new EBasicVer("insertMe");
DB.save(newBean);
@@ -60,7 +60,7 @@ public class TestTransparentPersist extends BaseTestCase {
DB.save(b0);
try (Transaction transaction = DB.beginTransaction()) {
- transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+ transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
EBasicVer found = DB.find(EBasicVer.class, b0.getId());
// make it dirty
@@ -88,7 +88,7 @@ public class TestTransparentPersist extends BaseTestCase {
EBasicVer newBean;
try (Transaction transaction = DB.beginTransaction()) {
- transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+ transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
EBasicVer found = DB.find(EBasicVer.class, b0.getId());
found.setName("auto dirty");
@@ -127,7 +127,7 @@ public class TestTransparentPersist extends BaseTestCase {
transPersist.save();
try (Transaction transaction = DB.beginTransaction()) {
- transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+ transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
EBasicVer found = DB.find(EBasicVer.class, transPersist.getId());
found.setName("Persisted automatically as dirty");
@@ -152,7 +152,7 @@ public class TestTransparentPersist extends BaseTestCase {
DB.save(order);
try (Transaction transaction = DB.beginTransaction()) {
- transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+ transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
Order foundOrder = DB.find(Order.class, order.getId());
foundOrder.setStatus(Order.Status.APPROVED);
@@ -188,7 +188,7 @@ public class TestTransparentPersist extends BaseTestCase {
LoggedSql.start();
try (Transaction transaction = DB.beginTransaction()) {
- transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
+ transaction.setAutoPersistUpdates(true); // EXPERIMENTAL feature
Order foundOrder = DB.find(Order.class, order.getId());
// we ONLY mutate the foreign key
From 6d8a1c9398951b2bffe51e1e9d951b971bfbcb91 Mon Sep 17 00:00:00 2001
From: Vladimir Konkov
Date: Mon, 5 Apr 2021 21:45:48 +0300
Subject: [PATCH 021/111] Explicit locking method withLock() is unaccessible on
query beans
---
.../src/main/java/io/ebean/typequery/TQRootBean.java | 4 ++--
.../src/test/java/org/querytest/QCustomerTest.java | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java
index 654e35e9d..728184cf4 100644
--- a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java
+++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java
@@ -679,7 +679,7 @@ public abstract class TQRootBean {
* Provides us with the ability to explicitly use Postgres
* SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks.
*/
- R withLock(Query.LockType lockType) {
+ public R withLock(Query.LockType lockType) {
query.withLock(lockType);
return root;
}
@@ -693,7 +693,7 @@ public abstract class TQRootBean {
* Provides us with the ability to explicitly use Postgres
* SHARE, KEY SHARE, NO KEY UPDATE and UPDATE row locks.
*/
- R withLock(Query.LockType lockType, Query.LockWait lockWait) {
+ public R withLock(Query.LockType lockType, Query.LockWait lockWait) {
query.withLock(lockType, lockWait);
return root;
}
diff --git a/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java b/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java
index 56aec1c51..867290e71 100644
--- a/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java
+++ b/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java
@@ -71,6 +71,7 @@ public class QCustomerTest {
// not found using other transaction
final Customer foundNot = new QCustomer()
.name.eq("explicitTransaction")
+ .withLock(Query.LockType.SHARE)
.findOne();
assertThat(foundNot).isNull();
From 9b04f20ed3a1c40de97826f682524d3a6757a77d Mon Sep 17 00:00:00 2001
From: Roman Parshikov
Date: Tue, 6 Apr 2021 13:32:57 +0800
Subject: [PATCH 022/111] Fix copy/paste typo
---
ebean-api/src/main/java/io/ebean/ExpressionList.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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();
From f7c1845f0c5dae997f27a799438fea02a7dadf2f Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Tue, 6 Apr 2021 19:58:02 +1200
Subject: [PATCH 023/111] #2177 - Fix where schema not provided by JDBC driver
For @Table with schema, using findNative with a JDBC driver that does not provide the schema this fix matches by just using the table name.
---
.../server/deploy/BeanDescriptor.java | 6 +--
.../server/deploy/BeanDescriptorTest.java | 53 ++++++++++++++++---
2 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java
index a2d902f13..e05c636bb 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java
@@ -2473,7 +2473,7 @@ public class BeanDescriptor implements BeanType, STreeType {
* Return the property path given the db table and column.
*/
public String findBeanPath(String schemaName, String tableName, String columnName) {
- if (matchBaseTable(schemaName, tableName)) {
+ if (matchBaseTable(tableName)) {
return columnPath.get(columnName);
}
BeanPropertyAssoc> assocProperty = tablePath.get(tableName);
@@ -2489,10 +2489,10 @@ public class BeanDescriptor implements BeanType, STreeType {
return null;
}
- private boolean matchBaseTable(String schemaName, String tableName) {
+ boolean matchBaseTable(String tableName) {
return tableName.isEmpty()
|| baseTable.equalsIgnoreCase(tableName)
- || baseTable.equalsIgnoreCase(schemaName + "." + tableName);
+ || baseTable.endsWith("." + tableName);
}
/**
diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java
index d4cbcbfbf..ab8ae6a87 100644
--- a/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java
+++ b/ebean-core/src/test/java/io/ebeaninternal/server/deploy/BeanDescriptorTest.java
@@ -4,21 +4,22 @@ import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.bean.EntityBean;
import io.ebean.plugin.Property;
+import io.ebeaninternal.server.core.CacheOptions;
+import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
+import io.ebeaninternal.server.deploy.meta.DeployIdentityMode;
+import io.ebeanservice.docstore.api.DocStoreBeanAdapter;
import org.junit.Test;
-import org.tests.model.basic.Animal;
-import org.tests.model.basic.AnimalShelter;
-import org.tests.model.basic.Cat;
-import org.tests.model.basic.Contact;
-import org.tests.model.basic.Country;
-import org.tests.model.basic.Customer;
-import org.tests.model.basic.Dog;
-import org.tests.model.basic.Order;
+import org.tests.model.basic.*;
import org.tests.model.bridge.BSite;
import org.tests.model.bridge.BUser;
import java.util.Collection;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class BeanDescriptorTest extends BaseTestCase {
@@ -88,6 +89,42 @@ public class BeanDescriptorTest extends BaseTestCase {
assertThat(props).extracting("name").contains("id", "status", "orderDate", "shipDate");
}
+ @Test
+ public void matchBaseTable() {
+ BeanDescriptor desc = getBeanDescriptor(Customer.class);
+ assertTrue(desc.matchBaseTable("o_customer"));
+ }
+
+ @Test
+ public void matchBaseTable_whenTableHasSchema_expect_matchRegardlessOfSchema() {
+
+ DeployBeanDescriptor deploy = mockDeployCustomer();
+
+ when(deploy.getBaseTable()).thenReturn("foo.o_customer");
+ BeanDescriptor> desc1 = new BeanDescriptor<>(mockOwner(), deploy);
+ assertTrue(desc1.matchBaseTable("o_customer"));
+
+ when(deploy.getBaseTable()).thenReturn("bar.o_customer");
+ BeanDescriptor> desc2 = new BeanDescriptor<>(mockOwner(), deploy);
+ assertTrue(desc2.matchBaseTable("o_customer"));
+ }
+
+ @SuppressWarnings("unchecked")
+ private DeployBeanDescriptor mockDeployCustomer() {
+ DeployBeanDescriptor deploy = mock(DeployBeanDescriptor.class);
+ when(deploy.getBeanType()).thenReturn(Customer.class);
+ when(deploy.getIdentityMode()).thenReturn(DeployIdentityMode.auto());
+ when(deploy.buildIdentityMode()).thenReturn(IdentityMode.NONE);
+ when(deploy.getCacheOptions()).thenReturn(CacheOptions.NO_CACHING);
+ return deploy;
+ }
+
+ private BeanDescriptorMap mockOwner() {
+ BeanDescriptorMap owner = mock(BeanDescriptorMap.class);
+ when(owner.createDocStoreBeanAdapter(any(), any())).thenReturn(mock(DocStoreBeanAdapter.class));
+ return owner;
+ }
+
@Test
public void merge_when_empty() {
From 3e97a4005ab34abbac6829ac7e8d70550427c96f Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Tue, 6 Apr 2021 20:09:09 +1200
Subject: [PATCH 024/111] Change TestCustomerFinder drop query plan threshold
for tests only
---
.../java/org/tests/query/finder/TestCustomerFinder.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java
index 8446f9d5b..468b165bb 100644
--- a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java
+++ b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java
@@ -55,7 +55,6 @@ public class TestCustomerFinder extends BaseTestCase {
assertThat(json1).contains("\"name\":\"txn.main\"");
assertThat(json1).contains("\"name\":\"orm.Customer.findList\"");
assertThat(json1).doesNotContain("\"sql\":\"select t0.id, t0.status, t0.name");
-
}
@Test
@@ -85,7 +84,6 @@ public class TestCustomerFinder extends BaseTestCase {
assertThat(customer.getName()).isEqualTo(customer1.getName());
assertThat(Customer.find.db().getName()).isEqualTo(DB.getDefault().getName());
-
}
@Test
@@ -178,7 +176,7 @@ public class TestCustomerFinder extends BaseTestCase {
// change default collect query plan threshold to 200 micros
QueryPlanInit init0 = new QueryPlanInit();
init0.setAll(true);
- init0.setThresholdMicros(200);
+ init0.setThresholdMicros(2);
final List plans = server().getMetaInfoManager().queryPlanInit(init0);
assertThat(plans.size()).isGreaterThan(1);
@@ -188,7 +186,7 @@ public class TestCustomerFinder extends BaseTestCase {
// change query plan threshold to 100 micros
QueryPlanInit init = new QueryPlanInit();
init.setAll(true);
- init.setThresholdMicros(100);
+ init.setThresholdMicros(1);
final List appliedToPlans = server().getMetaInfoManager().queryPlanInit(init);
assertThat(appliedToPlans.size()).isGreaterThan(4);
From bb1275f4f95aa43c34b392791b419f2e673bb6dc Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Tue, 6 Apr 2021 21:13:59 +1200
Subject: [PATCH 025/111] #2217 - Inserting an entity bean is skipped with a
String @Id property and no other properties set
---
.../server/core/PersistRequestBean.java | 7 ++
.../server/deploy/BeanDescriptor.java | 2 +-
.../server/persist/DefaultPersister.java | 2 +-
.../cache/personinfo/PersonCacheEmail.java | 4 +
.../tests/cache/personinfo/PersonOther.java | 73 +++++++++++++++++++
.../cache/personinfo/TestStringIdOnly.java | 30 ++++++++
6 files changed, 116 insertions(+), 2 deletions(-)
create mode 100644 ebean-core/src/test/java/org/tests/cache/personinfo/PersonOther.java
create mode 100644 ebean-core/src/test/java/org/tests/cache/personinfo/TestStringIdOnly.java
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
index eb48fc2ef..01c27fa0f 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/PersistRequestBean.java
@@ -1032,6 +1032,13 @@ public final class PersistRequestBean extends PersistRequest implements BeanP
}
}
+ /**
+ * Return if persist can be skipped on the reference only bean.
+ */
+ public boolean isSkipReference() {
+ return intercept.isReference() || (Flags.isRecurse(flags) && beanDescriptor.referenceIdPropertyOnly(intercept));
+ }
+
public boolean isReference() {
return beanDescriptor.isReference(intercept);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java
index a2d902f13..2e0e00b65 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptor.java
@@ -3134,7 +3134,7 @@ public class BeanDescriptor implements BeanType, STreeType {
return ebi.isReference() || referenceIdPropertyOnly(ebi);
}
- boolean referenceIdPropertyOnly(EntityBeanIntercept ebi) {
+ public boolean referenceIdPropertyOnly(EntityBeanIntercept ebi) {
return idOnlyReference && ebi.hasIdOnly(idPropertyIndex);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
index a7b21f0c8..935fbb6b8 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/DefaultPersister.java
@@ -447,7 +447,7 @@ public final class DefaultPersister implements Persister {
public void insert(EntityBean bean, Transaction t) {
PersistRequestBean> req = createRequest(bean, t, PersistRequest.Type.INSERT);
- if (req.isReference()) {
+ if (req.isSkipReference()) {
// skip insert on reference bean
return;
}
diff --git a/ebean-core/src/test/java/org/tests/cache/personinfo/PersonCacheEmail.java b/ebean-core/src/test/java/org/tests/cache/personinfo/PersonCacheEmail.java
index 58ddea0a2..144253edf 100644
--- a/ebean-core/src/test/java/org/tests/cache/personinfo/PersonCacheEmail.java
+++ b/ebean-core/src/test/java/org/tests/cache/personinfo/PersonCacheEmail.java
@@ -25,6 +25,10 @@ public class PersonCacheEmail {
this.email = email;
}
+ public PersonCacheEmail(String id) {
+ this.id = id;
+ }
+
public String getId() {
return id;
}
diff --git a/ebean-core/src/test/java/org/tests/cache/personinfo/PersonOther.java b/ebean-core/src/test/java/org/tests/cache/personinfo/PersonOther.java
new file mode 100644
index 000000000..b4b505125
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/cache/personinfo/PersonOther.java
@@ -0,0 +1,73 @@
+package org.tests.cache.personinfo;
+
+import io.ebean.annotation.WhenCreated;
+import io.ebean.annotation.WhenModified;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Version;
+import javax.validation.constraints.Size;
+import java.time.Instant;
+
+@Entity
+public class PersonOther {
+
+ @Id
+ @Size(max=128)
+ private String id;
+
+ private String email;
+
+ @WhenCreated
+ private Instant whenCreated;
+
+ @WhenModified
+ private Instant whenModified;
+
+ @Version
+ private long version;
+
+ public PersonOther(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public Instant getWhenCreated() {
+ return whenCreated;
+ }
+
+ public void setWhenCreated(Instant whenCreated) {
+ this.whenCreated = whenCreated;
+ }
+
+ public Instant getWhenModified() {
+ return whenModified;
+ }
+
+ public void setWhenModified(Instant whenModified) {
+ this.whenModified = whenModified;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ public void setVersion(long version) {
+ this.version = version;
+ }
+}
diff --git a/ebean-core/src/test/java/org/tests/cache/personinfo/TestStringIdOnly.java b/ebean-core/src/test/java/org/tests/cache/personinfo/TestStringIdOnly.java
new file mode 100644
index 000000000..6379491ff
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/cache/personinfo/TestStringIdOnly.java
@@ -0,0 +1,30 @@
+package org.tests.cache.personinfo;
+
+import io.ebean.BaseTestCase;
+import io.ebean.DB;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class TestStringIdOnly extends BaseTestCase {
+
+ @Test
+ public void insert() {
+
+ PersonCacheEmail b0 = new PersonCacheEmail("IdOnly");
+ DB.save(b0);
+
+ PersonCacheEmail found = DB.find(PersonCacheEmail.class, b0.getId());
+ assertThat(found).isNotNull();
+ }
+
+ @Test
+ public void insert_whenIdOnly() {
+
+ PersonOther b0 = new PersonOther("IdOnly");
+ DB.save(b0);
+
+ PersonOther found = DB.find(PersonOther.class, b0.getId());
+ assertThat(found).isNotNull();
+ }
+}
From f7f383d8f303682368096a9fdb52da50bcaf7e50 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Wed, 7 Apr 2021 13:38:34 +1200
Subject: [PATCH 026/111] No effective change - tidy tests
TestRawSqlPositionedParams, TestRawSqlUnparsedQuery
---
.../rawsql/TestRawSqlPositionedParams.java | 54 +++++++++----------
.../tests/rawsql/TestRawSqlUnparsedQuery.java | 29 +++++-----
2 files changed, 42 insertions(+), 41 deletions(-)
diff --git a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlPositionedParams.java b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlPositionedParams.java
index f1c3ef4fd..75d678fd6 100644
--- a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlPositionedParams.java
+++ b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlPositionedParams.java
@@ -1,38 +1,42 @@
package org.tests.rawsql;
import io.ebean.BaseTestCase;
-import io.ebean.Ebean;
-import io.ebean.Query;
+import io.ebean.DB;
import io.ebean.RawSql;
import io.ebean.RawSqlBuilder;
+import org.junit.Test;
import org.tests.model.basic.Customer;
import org.tests.model.basic.ResetBasicData;
-import org.junit.Test;
import java.util.List;
-import static org.junit.Assert.assertNotNull;
+import static org.assertj.core.api.Assertions.assertThat;
public class TestRawSqlPositionedParams extends BaseTestCase {
+ private static final RawSql RAWSQL_1 = RawSqlBuilder
+ .parse("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?")
+ .create();
+
+ private static final RawSql RAW_SQL_2 = RawSqlBuilder
+ .unparsed("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?")
+ .columnMapping("r.id", "id")
+ .columnMapping("r.name", "name")
+ .create();
+
@Test
public void test() {
ResetBasicData.reset();
- RawSql rawSql = RawSqlBuilder
- .parse("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?")
- .create();
+ List list = DB.find(Customer.class)
+ .setRawSql(RAWSQL_1)
+ .setParameter(1)
+ .setParameter("R%")
+ .where().lt("id", 2001)
+ .findList();
- Query query = Ebean.find(Customer.class);
- query.setRawSql(rawSql);
- query.setParameter(1, 1);
- query.setParameter(2, "R%");
- query.where().lt("id", 2001);
-
- List list = query.findList();
-
- assertNotNull(list);
+ assertThat(list).isNotNull();
}
@Test
@@ -40,18 +44,12 @@ public class TestRawSqlPositionedParams extends BaseTestCase {
ResetBasicData.reset();
- RawSql rawSql = RawSqlBuilder
- .unparsed("select r.id, r.name from o_customer r where r.id >= ? and r.name like ?")
- .columnMapping("r.id", "id")
- .columnMapping("r.name", "name").create();
+ List list = DB.find(Customer.class)
+ .setRawSql(RAW_SQL_2)
+ .setParameter(1)
+ .setParameter("R%")
+ .findList();
- Query query = Ebean.find(Customer.class);
- query.setRawSql(rawSql);
- query.setParameter(1, 1);
- query.setParameter(2, "R%");
-
- List list = query.findList();
-
- assertNotNull(list);
+ assertThat(list).isNotNull();
}
}
diff --git a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlUnparsedQuery.java b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlUnparsedQuery.java
index 8d900b15f..1e576f0b7 100644
--- a/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlUnparsedQuery.java
+++ b/ebean-core/src/test/java/org/tests/rawsql/TestRawSqlUnparsedQuery.java
@@ -1,19 +1,25 @@
package org.tests.rawsql;
import io.ebean.BaseTestCase;
-import io.ebean.Ebean;
-import io.ebean.Query;
+import io.ebean.DB;
import io.ebean.RawSql;
import io.ebean.RawSqlBuilder;
+import org.junit.Test;
import org.tests.model.basic.Customer;
import org.tests.model.basic.ResetBasicData;
-import org.junit.Assert;
-import org.junit.Test;
import java.util.List;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class TestRawSqlUnparsedQuery extends BaseTestCase {
+ private static final RawSql rawSql = RawSqlBuilder
+ .unparsed("select r.id, r.name from o_customer r where r.id >= :a and r.name like :b")
+ .columnMapping("r.id", "id")
+ .columnMapping("r.name", "name")
+ .create();
+
@Test
public void testDoubleUnparsedQuery() {
@@ -25,17 +31,14 @@ public class TestRawSqlUnparsedQuery extends BaseTestCase {
}
private static void test() {
- RawSql rawSql = RawSqlBuilder
- .unparsed("select r.id, r.name from o_customer r where r.id >= :a and r.name like :b")
- .columnMapping("r.id", "id").columnMapping("r.name", "name").create();
- Query query = Ebean.find(Customer.class);
- query.setRawSql(rawSql);
- query.setParameter("a", 1);
- query.setParameter("b", "R%");
+ List list = DB.find(Customer.class)
+ .setRawSql(rawSql)
+ .setParameter("a", 1)
+ .setParameter("b", "R%")
+ .findList();
- List list = query.findList();
- Assert.assertNotNull(list);
+ assertThat(list).isNotNull();
}
}
From 59793f3c018e1291ec4bf6d869dba4117aa1ca7c Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Wed, 7 Apr 2021 15:50:04 +1200
Subject: [PATCH 027/111] Improve javadoc for Transaction#setGetGeneratedKeys
More clearly document the limitation that we can't update beans that don't have id values
---
.../src/main/java/io/ebean/Transaction.java | 30 ++++++-------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/ebean-api/src/main/java/io/ebean/Transaction.java b/ebean-api/src/main/java/io/ebean/Transaction.java
index d4918e84e..d3e918c0d 100644
--- a/ebean-api/src/main/java/io/ebean/Transaction.java
+++ b/ebean-api/src/main/java/io/ebean/Transaction.java
@@ -339,15 +339,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 +389,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 +416,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 +447,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 +469,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 +485,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 +501,6 @@ public interface Transaction extends AutoCloseable {
* flush the batch if you like.
*
* Flushing occurs automatically when:
- *
*
* the batch size is reached
* A query is executed on the same transaction
@@ -533,11 +526,9 @@ public interface Transaction extends AutoCloseable {
* commit() rollback() and end() methods on the Transaction should still be
* used. Calling these methods on the Connection would be a big no no unless
* you know what you are doing.
- *
*
* Examples of when a developer may wish to use the connection directly are:
* Savepoints, advanced CLOB BLOB use and advanced stored procedure calls.
- *
*/
Connection getConnection();
@@ -545,17 +536,14 @@ public interface Transaction extends AutoCloseable {
* Add table modification information to the TransactionEvent.
*
* Use this in conjunction with getConnection() and raw JDBC.
- *
*
* This effectively informs Ebean of the data that has been changed by the
* transaction and this information is normally automatically handled by Ebean
* when you save entity beans or use UpdateSql etc.
- *
*
* If you use raw JDBC then you can use this method to inform Ebean for the
* tables that have been modified. Ebean uses this information to keep its
* caches in synch and maintain text indexes.
- *
*/
void addModification(String tableName, boolean inserts, boolean updates, boolean deletes);
From 4ee8d647b7ee91dd1e1c0dada43e70c3355f9421 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Wed, 7 Apr 2021 23:28:53 +1200
Subject: [PATCH 028/111] No effective change - tidy test TestCustomerFinder
---
.../java/org/tests/query/finder/TestCustomerFinder.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java
index 468b165bb..eeefe42c2 100644
--- a/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java
+++ b/ebean-core/src/test/java/org/tests/query/finder/TestCustomerFinder.java
@@ -31,7 +31,7 @@ public class TestCustomerFinder extends BaseTestCase {
runQueries();
StringBuilder buffer0 = new StringBuilder();
- server().getMetaInfoManager()
+ DB.getDefault().getMetaInfoManager()
.collectMetricsAsJson()
.withHeader(false)
.write(buffer0);
@@ -45,7 +45,7 @@ public class TestCustomerFinder extends BaseTestCase {
runQueries();
StringBuilder buffer1 = new StringBuilder();
- server().getMetaInfoManager()
+ DB.getDefault().getMetaInfoManager()
.collectMetricsAsJson()
.withHeader(false)
.write(buffer1);
@@ -193,7 +193,7 @@ public class TestCustomerFinder extends BaseTestCase {
// run queries again
runQueries();
- ServerMetrics metrics = server().getMetaInfoManager().collectMetrics();
+ ServerMetrics metrics = DB.getDefault().getMetaInfoManager().collectMetrics();
List planStats = metrics.getQueryMetrics();
assertThat(planStats.size()).isGreaterThan(4);
From 7f13ac9e5e7354954492ef23041435c5e4fa3b4d Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Thu, 8 Apr 2021 23:15:49 +1200
Subject: [PATCH 029/111] #2213 - Support autoPersistUpdates via TxScope
---
ebean-api/pom.xml | 2 +-
ebean-api/src/main/java/io/ebean/TxScope.java | 18 ++++++++
ebean-core/pom.xml | 2 +-
.../java/io/ebeaninternal/api/ScopeTrans.java | 4 ++
.../TestTransparentPersist.java | 43 +++++++++++++++++--
.../src/test/resources/logback-test.xml | 4 +-
6 files changed, 65 insertions(+), 8 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 4fe1468ec..cb8c1d67e 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -50,7 +50,7 @@
io.ebean
ebean-annotation
- 6.15
+ 7.0
diff --git a/ebean-api/src/main/java/io/ebean/TxScope.java b/ebean-api/src/main/java/io/ebean/TxScope.java
index ee9fdca7b..59d9f6971 100644
--- a/ebean-api/src/main/java/io/ebean/TxScope.java
+++ b/ebean-api/src/main/java/io/ebean/TxScope.java
@@ -2,6 +2,7 @@ package io.ebean;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.TxIsolation;
+import io.ebean.annotation.TxOption;
import io.ebean.annotation.TxType;
import java.util.ArrayList;
@@ -33,6 +34,8 @@ public final class TxScope {
private TxIsolation isolation;
+ private TxOption autoPersistUpdates;
+
private PersistBatch batch;
private PersistBatch batchOnCascade;
@@ -123,6 +126,13 @@ public final class TxScope {
+ "] serverName[" + serverName + "] rollbackFor[" + rollbackFor + "] noRollbackFor[" + noRollbackFor + "]";
}
+ /**
+ * Return the AutoPersistUpdates mode as a nullable Boolean.
+ */
+ public Boolean getAutoPersistUpdates() {
+ return autoPersistUpdates == null ? null : autoPersistUpdates.asBoolean();
+ }
+
/**
* Return true if PersistBatch has been set.
*/
@@ -176,6 +186,14 @@ public final class TxScope {
return this;
}
+ /**
+ * Set the autoPersistUpdates mode.
+ */
+ public TxScope setAutoPersistUpdates(TxOption autoPersistUpdates) {
+ this.autoPersistUpdates = autoPersistUpdates;
+ return this;
+ }
+
/**
* Return the transaction profile id.
*/
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 3652ba9a3..4b37905a9 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -302,7 +302,7 @@
io.ebean
ebean-maven-plugin
- 12.8.1
+ 12.8.2-SNAPSHOT
test
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/ScopeTrans.java b/ebean-core/src/main/java/io/ebeaninternal/api/ScopeTrans.java
index 5fbb03f25..631b6dfb8 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/ScopeTrans.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/ScopeTrans.java
@@ -73,6 +73,10 @@ public class ScopeTrans {
restoreBatchGeneratedKeys = transaction.getBatchGetGeneratedKeys();
restoreBatchFlushOnQuery = transaction.isFlushOnQuery();
}
+ Boolean autoPersistUpdates = txScope.getAutoPersistUpdates();
+ if (autoPersistUpdates != null) {
+ transaction.setAutoPersistUpdates(autoPersistUpdates);
+ }
if (txScope.isBatchSet()) {
transaction.setBatchMode(txScope.isBatchMode());
}
diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
index 963cc1dcb..a169145eb 100644
--- a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
+++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
@@ -1,9 +1,7 @@
package org.tests.transparentpersist;
-import io.ebean.BaseTestCase;
-import io.ebean.DB;
-import io.ebean.Database;
-import io.ebean.Transaction;
+import io.ebean.*;
+import io.ebean.annotation.*;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeantest.LoggedSql;
import org.junit.Test;
@@ -219,6 +217,43 @@ public class TestTransparentPersist extends BaseTestCase {
DB.delete(Customer.class, c0.getId());
}
+ @Test
+ public void txScope_setAutoPersistUpdates() {
+
+ EBasicVer b0 = new EBasicVer("txScopeUpdate");
+ b0.save();
+
+ DB.execute(TxScope.required().setAutoPersistUpdates(TxOption.ON), () -> {
+ EBasicVer found = DB.find(EBasicVer.class, b0.getId());
+ found.setName("mutable txScope bean");
+ });
+
+ EBasicVer after = DB.find(EBasicVer.class, b0.getId());
+ assertThat(after.getName()).isEqualTo("mutable txScope bean");
+
+ DB.delete(after);
+ }
+
+// @Test
+// public void txn_setAutoPersistUpdates() {
+//
+// EBasicVer b0 = new EBasicVer("txn autoPersistUpdates ON");
+// b0.save();
+//
+// performUpdate(b0);
+//
+// EBasicVer after = DB.find(EBasicVer.class, b0.getId());
+// assertThat(after.getName()).isEqualTo("mutated with autoPersistUpdates ON");
+//
+// DB.delete(after);
+// }
+//
+// @Transactional(autoPersistUpdates = TxOption.ON)
+// private void performUpdate(EBasicVer b0) {
+// EBasicVer found = DB.find(EBasicVer.class, b0.getId());
+// found.setName("mutated with autoPersistUpdates ON");
+// }
+
@Test
public void simulate_transparentPersistence_forSimpleUpdate() {
diff --git a/ebean-core/src/test/resources/logback-test.xml b/ebean-core/src/test/resources/logback-test.xml
index 164ff73d3..1b8a60a9b 100644
--- a/ebean-core/src/test/resources/logback-test.xml
+++ b/ebean-core/src/test/resources/logback-test.xml
@@ -79,8 +79,8 @@
-
-
+
+
From 06802896ef0b9412c8fb153365dc1866c7fb588d Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 9 Apr 2021 16:17:58 +1200
Subject: [PATCH 030/111] #2213 Bump agent for
@Transactional(autoPersistUpdates = TxOption.ON)
---
ebean-bom/pom.xml | 4 +-
ebean-core/pom.xml | 2 +-
.../TestTransparentPersist.java | 38 +++++++++----------
ebean-ddl-generator/pom.xml | 2 +-
kotlin-querybean-generator/pom.xml | 2 +-
5 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 401f6dbdf..7ab7bb0e9 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -18,8 +18,8 @@
12.4.0
4.1
7.0
- 12.8.1
- 12.8.1
+ 12.8.2
+ 12.8.2
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 4b37905a9..2e403ef17 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -302,7 +302,7 @@
io.ebean
ebean-maven-plugin
- 12.8.2-SNAPSHOT
+ 12.8.2
test
diff --git a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
index a169145eb..75d767b3b 100644
--- a/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
+++ b/ebean-core/src/test/java/org/tests/transparentpersist/TestTransparentPersist.java
@@ -234,25 +234,25 @@ public class TestTransparentPersist extends BaseTestCase {
DB.delete(after);
}
-// @Test
-// public void txn_setAutoPersistUpdates() {
-//
-// EBasicVer b0 = new EBasicVer("txn autoPersistUpdates ON");
-// b0.save();
-//
-// performUpdate(b0);
-//
-// EBasicVer after = DB.find(EBasicVer.class, b0.getId());
-// assertThat(after.getName()).isEqualTo("mutated with autoPersistUpdates ON");
-//
-// DB.delete(after);
-// }
-//
-// @Transactional(autoPersistUpdates = TxOption.ON)
-// private void performUpdate(EBasicVer b0) {
-// EBasicVer found = DB.find(EBasicVer.class, b0.getId());
-// found.setName("mutated with autoPersistUpdates ON");
-// }
+ @Test
+ public void txn_setAutoPersistUpdates() {
+
+ EBasicVer b0 = new EBasicVer("txn autoPersistUpdates ON");
+ b0.save();
+
+ performUpdate(b0);
+
+ EBasicVer after = DB.find(EBasicVer.class, b0.getId());
+ assertThat(after.getName()).isEqualTo("mutated with autoPersistUpdates ON");
+
+ DB.delete(after);
+ }
+
+ @Transactional(autoPersistUpdates = TxOption.ON)
+ private void performUpdate(EBasicVer b0) {
+ EBasicVer found = DB.find(EBasicVer.class, b0.getId());
+ found.setName("mutated with autoPersistUpdates ON");
+ }
@Test
public void simulate_transparentPersistence_forSimpleUpdate() {
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 421166e46..edabcce4f 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -76,7 +76,7 @@
io.ebean
ebean-maven-plugin
- 12.8.1
+ 12.8.2
test
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 70432f360..40d38fe36 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -146,7 +146,7 @@
io.ebean
ebean-maven-plugin
- 12.8.1
+ 12.8.2
test
From fc174c8988f7eb47989c0d84b701e225919578e3 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 9 Apr 2021 17:49:07 +1200
Subject: [PATCH 031/111] [maven-release-plugin] prepare release
ebean-parent-12.8.2
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index cb8c1d67e..27641ad7e 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index 700861dd9..5d855889e 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.2
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 7ab7bb0e9..37d9aba2c 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-api
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-core-type
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-ddl-generator
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-externalmapping-api
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-externalmapping-xml
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-autotune
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-querybean
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
querybean-generator
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
io.ebean
kotlin-querybean-generator
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
io.ebean
ebean-test
- 12.8.2-SNAPSHOT
+ 12.8.2
test
io.ebean
ebean-postgis
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-redis
- 12.8.2-SNAPSHOT
+ 12.8.2
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index be8b15507..f57b0876e 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.8.2-SNAPSHOT
+ 12.8.2
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 2e403ef17..cfd18d306 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.2
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-core-type
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-externalmapping-api
- 12.8.2-SNAPSHOT
+ 12.8.2
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index edabcce4f..f6efd42b5 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index 32a98a767..a5fc4063a 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index 029f345fc..2b70daecf 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.2
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.8.2-SNAPSHOT
+ 12.8.2
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
test
io.ebean
ebean-ddl-generator
- 12.8.2-SNAPSHOT
+ 12.8.2
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index 6528624f3..376235aef 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.8.2-SNAPSHOT
+ 12.8.2
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index 86d02f68a..a213b74b7 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.8.2-SNAPSHOT
+ 12.8.2
test
io.ebean
querybean-generator
- 12.8.2-SNAPSHOT
+ 12.8.2
test
io.ebean
ebean-test
- 12.8.2-SNAPSHOT
+ 12.8.2
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index 1d3a74a49..35689ff88 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
io.ebean
ebean-querybean
- 12.8.2-SNAPSHOT
+ 12.8.2
test
io.ebean
querybean-generator
- 12.8.2-SNAPSHOT
+ 12.8.2
test
io.ebean
ebean-test
- 12.8.2-SNAPSHOT
+ 12.8.2
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index 65e0d345c..0f9670dc6 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
provided
io.ebean
ebean-ddl-generator
- 12.8.2-SNAPSHOT
+ 12.8.2
diff --git a/ebean/pom.xml b/ebean/pom.xml
index b293a20bc..fb3fce888 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
io.ebean
ebean-querybean
- 12.8.2-SNAPSHOT
+ 12.8.2
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 40d38fe36..c8a470b11 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.8.2-SNAPSHOT
+ 12.8.2
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.8.2-SNAPSHOT
+ 12.8.2
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.8.2-SNAPSHOT
+ 12.8.2
test
diff --git a/pom.xml b/pom.xml
index a0ce632a3..87457c583 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.8.2-SNAPSHOT
+ 12.8.2
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.2
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index be174f512..569bd963f 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2-SNAPSHOT
+ 12.8.2
querybean generator
From 65b282a056492f096794e80189cff9d743558464 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 9 Apr 2021 17:49:16 +1200
Subject: [PATCH 032/111] [maven-release-plugin] prepare for next development
iteration
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 27641ad7e..92c01ccfb 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index 5d855889e..e3b77f33e 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.2
+ ebean-parent-12.8.0
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 37d9aba2c..488bce1cd 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-api
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-core-type
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-ddl-generator
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-externalmapping-xml
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-autotune
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-querybean
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
querybean-generator
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
io.ebean
kotlin-querybean-generator
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
io.ebean
ebean-test
- 12.8.2
+ 12.8.3-SNAPSHOT
test
io.ebean
ebean-postgis
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-redis
- 12.8.2
+ 12.8.3-SNAPSHOT
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index f57b0876e..41b6d4c6d 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.8.2
+ 12.8.3-SNAPSHOT
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index cfd18d306..94820c06d 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.2
+ ebean-parent-12.8.0
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-core-type
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.8.2
+ 12.8.3-SNAPSHOT
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index f6efd42b5..77feacd15 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index a5fc4063a..79278c962 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index 2b70daecf..9c948ce06 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.2
+ ebean-parent-12.8.0
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.8.2
+ 12.8.3-SNAPSHOT
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
test
io.ebean
ebean-ddl-generator
- 12.8.2
+ 12.8.3-SNAPSHOT
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index 376235aef..8c841697c 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.8.2
+ 12.8.3-SNAPSHOT
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index a213b74b7..798ccf976 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.8.2
+ 12.8.3-SNAPSHOT
test
io.ebean
querybean-generator
- 12.8.2
+ 12.8.3-SNAPSHOT
test
io.ebean
ebean-test
- 12.8.2
+ 12.8.3-SNAPSHOT
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index 35689ff88..793fab680 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
io.ebean
ebean-querybean
- 12.8.2
+ 12.8.3-SNAPSHOT
test
io.ebean
querybean-generator
- 12.8.2
+ 12.8.3-SNAPSHOT
test
io.ebean
ebean-test
- 12.8.2
+ 12.8.3-SNAPSHOT
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index 0f9670dc6..d7f7c563a 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
provided
io.ebean
ebean-ddl-generator
- 12.8.2
+ 12.8.3-SNAPSHOT
diff --git a/ebean/pom.xml b/ebean/pom.xml
index fb3fce888..8881210b6 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
io.ebean
ebean-querybean
- 12.8.2
+ 12.8.3-SNAPSHOT
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index c8a470b11..4b957878f 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.8.2
+ 12.8.3-SNAPSHOT
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.8.2
+ 12.8.3-SNAPSHOT
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.8.2
+ 12.8.3-SNAPSHOT
test
diff --git a/pom.xml b/pom.xml
index 87457c583..10f7d260d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.8.2
+ 12.8.3-SNAPSHOT
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.2
+ ebean-parent-12.8.0
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index 569bd963f..5d6d29dc6 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.2
+ 12.8.3-SNAPSHOT
querybean generator
From 9d54b264ad536ed8564afe3d337af693de3e713d Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Mon, 19 Apr 2021 17:04:57 +1200
Subject: [PATCH 033/111] #2219 - Compile error with ZonedDateTime and query
beans - type argument java.time.ZonedDateTime is not within bounds of
type-variable D
---
.../io/ebean/typequery/PZonedDateTime.java | 50 +++++++++++++++++++
.../test/java/org/example/domain/Contact.java | 29 +++++++----
.../test/java/org/querytest/QContactTest.java | 4 +-
.../querybean/generator/PropertyTypeMap.java | 6 +--
.../querybean/generator/PropertyTypeMap.java | 6 +--
5 files changed, 77 insertions(+), 18 deletions(-)
create mode 100644 ebean-querybean/src/main/java/io/ebean/typequery/PZonedDateTime.java
diff --git a/ebean-querybean/src/main/java/io/ebean/typequery/PZonedDateTime.java b/ebean-querybean/src/main/java/io/ebean/typequery/PZonedDateTime.java
new file mode 100644
index 000000000..e233449ef
--- /dev/null
+++ b/ebean-querybean/src/main/java/io/ebean/typequery/PZonedDateTime.java
@@ -0,0 +1,50 @@
+package io.ebean.typequery;
+
+import java.time.ZonedDateTime;
+
+/**
+ * ZonedDateTime property.
+ *
+ * @param the root query bean type
+ */
+public class PZonedDateTime extends PBaseCompareable {
+
+ /**
+ * Construct with a property name and root instance.
+ *
+ * @param name property name
+ * @param root the root query bean instance
+ */
+ public PZonedDateTime(String name, R root) {
+ super(name, root);
+ }
+
+ /**
+ * Construct with additional path prefix.
+ */
+ public PZonedDateTime(String name, R root, String prefix) {
+ super(name, root, prefix);
+ }
+
+ /**
+ * Same as greater than.
+ *
+ * @param value the equal to bind value
+ * @return the root query bean instance
+ */
+ public R after(ZonedDateTime value) {
+ expr().gt(_name, value);
+ return _root;
+ }
+
+ /**
+ * Same as less than.
+ *
+ * @param value the equal to bind value
+ * @return the root query bean instance
+ */
+ public R before(ZonedDateTime value) {
+ expr().lt(_name, value);
+ return _root;
+ }
+}
diff --git a/ebean-querybean/src/test/java/org/example/domain/Contact.java b/ebean-querybean/src/test/java/org/example/domain/Contact.java
index 00035d80a..2b5fe9f53 100644
--- a/ebean-querybean/src/test/java/org/example/domain/Contact.java
+++ b/ebean-querybean/src/test/java/org/example/domain/Contact.java
@@ -3,6 +3,7 @@ package org.example.domain;
import io.ebean.annotation.DbArray;
import javax.persistence.*;
+import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -11,33 +12,35 @@ import java.util.Map;
* Contact entity bean.
*/
@Entity
-@Table(name="be_contact")
+@Table(name = "be_contact")
public class Contact extends BaseModel {
@DbArray
- List phoneNumbers = new ArrayList();
+ List phoneNumbers = new ArrayList<>();
- @Column(length=50)
+ @Column(length = 50)
String firstName;
- @Column(length=50)
+ @Column(length = 50)
String lastName;
- @Column(length=200)
+ @Column(length = 200)
String email;
- @Column(length=20)
+ @Column(length = 20)
String phone;
- @ManyToOne(optional=false)
+ ZonedDateTime zoneDateTime;
+
+ @ManyToOne(optional = false)
Customer customer;
@OneToMany(mappedBy = "contact")
List notes;
@OneToMany(cascade = CascadeType.PERSIST)
- @MapKey(name="key")
- Map others;
+ @MapKey(name = "key")
+ Map others;
/**
* Default constructor.
@@ -85,6 +88,14 @@ public class Contact extends BaseModel {
this.phone = phone;
}
+ public ZonedDateTime getZoneDateTime() {
+ return zoneDateTime;
+ }
+
+ public void setZoneDateTime(ZonedDateTime zoneDateTime) {
+ this.zoneDateTime = zoneDateTime;
+ }
+
public Customer getCustomer() {
return customer;
}
diff --git a/ebean-querybean/src/test/java/org/querytest/QContactTest.java b/ebean-querybean/src/test/java/org/querytest/QContactTest.java
index ff37f789e..ef0d5a01b 100644
--- a/ebean-querybean/src/test/java/org/querytest/QContactTest.java
+++ b/ebean-querybean/src/test/java/org/querytest/QContactTest.java
@@ -3,13 +3,15 @@ package org.querytest;
import org.example.domain.query.QContact;
import org.junit.Test;
+import java.time.ZonedDateTime;
+
public class QContactTest {
@Test
public void test_oneToManyMap() {
-
new QContact()
.others.fetch()
+ .zoneDateTime.before(ZonedDateTime.now())
.findList();
}
}
diff --git a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/PropertyTypeMap.java b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/PropertyTypeMap.java
index f5676f060..6afc8a6e3 100644
--- a/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/PropertyTypeMap.java
+++ b/kotlin-querybean-generator/src/main/java/io/ebean/querybean/generator/PropertyTypeMap.java
@@ -25,10 +25,9 @@ class PropertyTypeMap {
*/
private final PropertyType dbJsonType = new PropertyType("PJson");
- private Map map = new HashMap<>();
+ private final Map map = new HashMap<>();
PropertyTypeMap() {
-
map.put("boolean", new PropertyType("PBoolean"));
map.put("short", new PropertyType("PShort"));
map.put("int", new PropertyType("PInteger"));
@@ -57,7 +56,6 @@ class PropertyTypeMap {
addType(Locale.class);
addType(File.class);
addType(InetAddress.class);
-
map.put(URI.class.getName(), new PropertyType("PUri"));
map.put(URL.class.getName(), new PropertyType("PUrl"));
map.put(UUID.class.getName(), new PropertyType("PUuid"));
@@ -74,7 +72,6 @@ class PropertyTypeMap {
}
private void addJava8Types() {
-
try {
Class.forName("java.time.Instant");
} catch (ClassNotFoundException e) {
@@ -94,6 +91,7 @@ class PropertyTypeMap {
addType(java.time.YearMonth.class);
addType(java.time.ZoneId.class);
addType(java.time.ZoneOffset.class);
+ addType(java.time.ZonedDateTime.class);
}
private void addJodaTypes() {
diff --git a/querybean-generator/src/main/java/io/ebean/querybean/generator/PropertyTypeMap.java b/querybean-generator/src/main/java/io/ebean/querybean/generator/PropertyTypeMap.java
index b60a42cd7..fa35c72fa 100644
--- a/querybean-generator/src/main/java/io/ebean/querybean/generator/PropertyTypeMap.java
+++ b/querybean-generator/src/main/java/io/ebean/querybean/generator/PropertyTypeMap.java
@@ -25,10 +25,9 @@ class PropertyTypeMap {
*/
private final PropertyType dbJsonType = new PropertyType("PJson");
- private Map map = new HashMap<>();
+ private final Map map = new HashMap<>();
PropertyTypeMap() {
-
map.put("boolean", new PropertyType("PBoolean"));
map.put("short", new PropertyType("PShort"));
map.put("int", new PropertyType("PInteger"));
@@ -57,7 +56,6 @@ class PropertyTypeMap {
map.put("java.lang.Class>", new PropertyType("PClass"));
addType(File.class);
addType(InetAddress.class);
-
map.put(URI.class.getName(), new PropertyType("PUri"));
map.put(URL.class.getName(), new PropertyType("PUrl"));
map.put(UUID.class.getName(), new PropertyType("PUuid"));
@@ -73,7 +71,6 @@ class PropertyTypeMap {
}
private void addJava8Types() {
-
try {
Class.forName("java.time.Instant");
} catch (ClassNotFoundException e) {
@@ -93,6 +90,7 @@ class PropertyTypeMap {
addType(java.time.YearMonth.class);
addType(java.time.ZoneId.class);
addType(java.time.ZoneOffset.class);
+ addType(java.time.ZonedDateTime.class);
}
private void addJodaTypes() {
From 2d719c5b37f18c8ba2cc2189fd459d73c858dcf7 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Mon, 19 Apr 2021 20:08:38 +1200
Subject: [PATCH 034/111] #2218 - @Encrypted columns on Oracle. The identifier
alias starts with an underscore (ORA-00911)
Change to use zx__ for the encryption column alias prefix rather than _e_
---
.../io/ebeaninternal/server/core/DtoQueryRequest.java | 7 +++++--
.../java/io/ebeaninternal/server/core/EncryptAlias.java | 8 ++++++++
.../java/io/ebeaninternal/server/deploy/BeanProperty.java | 5 ++++-
.../io/ebeaninternal/server/core/DtoQueryRequestTest.java | 8 ++++----
4 files changed, 21 insertions(+), 7 deletions(-)
create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/core/EncryptAlias.java
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java
index 120e98a27..2372ed7c3 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java
@@ -23,6 +23,9 @@ import java.util.function.Predicate;
*/
public final class DtoQueryRequest extends AbstractSqlQueryRequest {
+ private static final String ENC_PREFIX = EncryptAlias.PREFIX;
+ private static final String ENC_PREFIX_UPPER = EncryptAlias.PREFIX.toUpperCase();
+
private final SpiDtoQuery query;
private final DtoQueryEngine queryEngine;
@@ -133,9 +136,9 @@ public final class DtoQueryRequest extends AbstractSqlQueryRequest {
}
static String parseColumn(String columnLabel) {
- if (columnLabel.startsWith("_e_") || columnLabel.startsWith("_E_")) {
+ if (columnLabel.startsWith(ENC_PREFIX) || columnLabel.startsWith(ENC_PREFIX_UPPER)) {
// encrypted column alias in the form _e__
- final int pos = columnLabel.indexOf("_", 3);
+ final int pos = columnLabel.indexOf("_", 4);
if (pos > -1) {
return columnLabel.substring(pos + 1);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/EncryptAlias.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/EncryptAlias.java
new file mode 100644
index 000000000..e73a2a9e9
--- /dev/null
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/EncryptAlias.java
@@ -0,0 +1,8 @@
+package io.ebeaninternal.server.core;
+
+/**
+ * Used to create column alias for encrypted columns.
+ */
+public interface EncryptAlias {
+ String PREFIX = "zx__";
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
index d3b1f429b..270415a22 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
@@ -18,6 +18,7 @@ import io.ebeaninternal.api.SpiExpressionRequest;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.api.json.SpiJsonReader;
import io.ebeaninternal.api.json.SpiJsonWriter;
+import io.ebeaninternal.server.core.EncryptAlias;
import io.ebeaninternal.server.core.InternString;
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedProperty;
import io.ebeaninternal.server.deploy.generatedproperty.GeneratedWhenCreated;
@@ -65,6 +66,8 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
private static final Logger logger = LoggerFactory.getLogger(BeanProperty.class);
+ private static final String ENC_PREFIX = " " + EncryptAlias.PREFIX;
+
/**
* Flag to mark this is the id property.
*/
@@ -531,7 +534,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
* Return the SQL for the column including decryption function and column alias.
*/
private String getDecryptSqlWithColumnAlias(String tableAlias) {
- return dbEncryptFunction.getDecryptSql(tableAlias + "." + this.getDbColumn()) + " _e_" + tableAlias + "_" + this.getDbColumn();
+ return dbEncryptFunction.getDecryptSql(tableAlias + "." + this.getDbColumn()) + ENC_PREFIX + tableAlias + "_" + this.getDbColumn();
}
@Override
diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/core/DtoQueryRequestTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/core/DtoQueryRequestTest.java
index f8bdd66bd..4b85f18f1 100644
--- a/ebean-core/src/test/java/io/ebeaninternal/server/core/DtoQueryRequestTest.java
+++ b/ebean-core/src/test/java/io/ebeaninternal/server/core/DtoQueryRequestTest.java
@@ -11,10 +11,10 @@ public class DtoQueryRequestTest {
public void testParse() {
assertEquals("foo", DtoQueryRequest.parseColumn("foo"));
- assertEquals("bar", DtoQueryRequest.parseColumn("_e_t0_bar"));
- assertEquals("BAR", DtoQueryRequest.parseColumn("_E_T0_BAR"));
- assertEquals("baz", DtoQueryRequest.parseColumn("_e_t42_baz"));
- assertEquals("BAZ", DtoQueryRequest.parseColumn("_E_T42_BAZ"));
+ assertEquals("bar", DtoQueryRequest.parseColumn("zx__t0_bar"));
+ assertEquals("BAR", DtoQueryRequest.parseColumn("ZX__T0_BAR"));
+ assertEquals("baz", DtoQueryRequest.parseColumn("zx__t42_baz"));
+ assertEquals("BAZ", DtoQueryRequest.parseColumn("ZX__T42_BAZ"));
assertEquals("e_t42_nope", DtoQueryRequest.parseColumn("e_t42_nope"));
assertEquals("_f_t42_nope", DtoQueryRequest.parseColumn("_f_t42_nope"));
From bb6ff866c76e068fd6030189e1df01f834b442d1 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Mon, 19 Apr 2021 21:37:05 +1200
Subject: [PATCH 035/111] #2220 - DDL generation of nullable columns expected
with nullable Embedded containing non null properties
---
ebean-core/pom.xml | 2 +-
.../server/deploy/BeanPropertyAssocManySqlHelp.java | 6 +++---
.../server/deploy/visitor/BaseTablePropertyVisitor.java | 6 ++++--
.../server/deploy/visitor/BeanPropertyVisitor.java | 4 ++--
.../server/deploy/visitor/VisitProperties.java | 2 +-
.../java/org/tests/model/embedded/EEmbDatePeriod.java | 4 ++++
.../model/build/ModelBuildPropertyVisitor.java | 8 ++++----
7 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 94820c06d..c07b3062c 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -72,7 +72,7 @@
io.ebean
ebean-ddl-generator
- 12.6.1
+ 12.8.4a
test
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManySqlHelp.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManySqlHelp.java
index 398713a18..06a2a2145 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManySqlHelp.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanPropertyAssocManySqlHelp.java
@@ -81,18 +81,18 @@ class BeanPropertyAssocManySqlHelp {
@Override
public void visitOneImported(BeanPropertyAssocOne> p) {
-
+ // do nothing
}
@Override
- public void visitScalar(BeanProperty p) {
+ public void visitScalar(BeanProperty p, boolean allowNonNull) {
sb.append(",").append(p.getDbColumn());
colCount++;
}
@Override
public void visitEnd() {
-
+ // do nothing
}
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/BaseTablePropertyVisitor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/BaseTablePropertyVisitor.java
index cc23a5c1f..e6741d12a 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/BaseTablePropertyVisitor.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/BaseTablePropertyVisitor.java
@@ -44,9 +44,11 @@ public abstract class BaseTablePropertyVisitor implements BeanPropertyVisitor {
public abstract void visitOneImported(BeanPropertyAssocOne> p);
/**
- * Override this method for normal scalar property.
+ * Override this method for normal scalar property. With allowNonNull
+ * used with properties of Embedded beans that can only be Nonnull when
+ * the Embedded bean is Nonnull.
*/
@Override
- public abstract void visitScalar(BeanProperty p);
+ public abstract void visitScalar(BeanProperty p, boolean allowNonNull);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/BeanPropertyVisitor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/BeanPropertyVisitor.java
index 1cadc2b1b..dd0dd7c6e 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/BeanPropertyVisitor.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/BeanPropertyVisitor.java
@@ -40,8 +40,8 @@ public interface BeanPropertyVisitor {
void visitEmbeddedScalar(BeanProperty p, BeanPropertyAssocOne> embedded);
/**
- * Visit a scalar property.
+ * Visit a scalar property specify allowing non-null (e.g. embedded bean scalar properties).
*/
- void visitScalar(BeanProperty p);
+ void visitScalar(BeanProperty p, boolean allowNonNull);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/VisitProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/VisitProperties.java
index deab1104c..5363b0add 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/VisitProperties.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/visitor/VisitProperties.java
@@ -72,7 +72,7 @@ public class VisitProperties {
} else {
// simple scalar type
- pv.visitScalar(p);
+ pv.visitScalar(p, true);
}
}
diff --git a/ebean-core/src/test/java/org/tests/model/embedded/EEmbDatePeriod.java b/ebean-core/src/test/java/org/tests/model/embedded/EEmbDatePeriod.java
index 50cb225a3..2542a066b 100644
--- a/ebean-core/src/test/java/org/tests/model/embedded/EEmbDatePeriod.java
+++ b/ebean-core/src/test/java/org/tests/model/embedded/EEmbDatePeriod.java
@@ -1,12 +1,16 @@
package org.tests.model.embedded;
+import io.ebean.annotation.NotNull;
+
import javax.persistence.Embeddable;
import java.util.Date;
@Embeddable
public class EEmbDatePeriod {
+ @NotNull
Date date1;
+ @NotNull
Date date2;
public Date getDate1() {
diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/build/ModelBuildPropertyVisitor.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/build/ModelBuildPropertyVisitor.java
index 7b13cf581..3a7457a56 100644
--- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/build/ModelBuildPropertyVisitor.java
+++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/build/ModelBuildPropertyVisitor.java
@@ -175,7 +175,8 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
if (p instanceof BeanPropertyAssocOne) {
visitOneImported((BeanPropertyAssocOne>)p);
} else {
- visitScalar(p);
+ // only allow Nonnull if embedded is Nonnull
+ visitScalar(p, !embedded.isNullable());
}
if (embedded.isId()) {
// compound primary key
@@ -259,8 +260,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
}
@Override
- public void visitScalar(BeanProperty p) {
-
+ public void visitScalar(BeanProperty p, boolean allowNonNull) {
if (p.isSecondaryTable()) {
lastColumn = null;
return;
@@ -292,7 +292,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
}
} else {
col.setDefaultValue(p.getDbColumnDefault());
- if (!p.isNullable() || p.isDDLNotNull()) {
+ if (allowNonNull && (!p.isNullable() || p.isDDLNotNull())) {
col.setNotnull(true);
}
}
From 9eb54da2dc29e03e495abedd84a97590ece3bc6e Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Mon, 19 Apr 2021 21:40:07 +1200
Subject: [PATCH 036/111] [maven-release-plugin] prepare release
ebean-parent-12.8.3
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 92c01ccfb..1dfb09ea5 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index e3b77f33e..d02ceb219 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.3
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 488bce1cd..01aff5126 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-api
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-core-type
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-ddl-generator
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-externalmapping-api
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-externalmapping-xml
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-autotune
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-querybean
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
querybean-generator
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
io.ebean
kotlin-querybean-generator
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
io.ebean
ebean-test
- 12.8.3-SNAPSHOT
+ 12.8.3
test
io.ebean
ebean-postgis
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-redis
- 12.8.3-SNAPSHOT
+ 12.8.3
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index 41b6d4c6d..1bee819fd 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.8.3-SNAPSHOT
+ 12.8.3
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index c07b3062c..c395097e6 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.3
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-core-type
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-externalmapping-api
- 12.8.3-SNAPSHOT
+ 12.8.3
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 77feacd15..959230160 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index 79278c962..3031bebb8 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index 9c948ce06..311a6f776 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.3
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.8.3-SNAPSHOT
+ 12.8.3
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
test
io.ebean
ebean-ddl-generator
- 12.8.3-SNAPSHOT
+ 12.8.3
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index 8c841697c..a254289cf 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.8.3-SNAPSHOT
+ 12.8.3
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index 798ccf976..252e28c54 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.8.3-SNAPSHOT
+ 12.8.3
test
io.ebean
querybean-generator
- 12.8.3-SNAPSHOT
+ 12.8.3
test
io.ebean
ebean-test
- 12.8.3-SNAPSHOT
+ 12.8.3
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index 793fab680..c238e7c7d 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
io.ebean
ebean-querybean
- 12.8.3-SNAPSHOT
+ 12.8.3
test
io.ebean
querybean-generator
- 12.8.3-SNAPSHOT
+ 12.8.3
test
io.ebean
ebean-test
- 12.8.3-SNAPSHOT
+ 12.8.3
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index d7f7c563a..9b13477da 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
provided
io.ebean
ebean-ddl-generator
- 12.8.3-SNAPSHOT
+ 12.8.3
diff --git a/ebean/pom.xml b/ebean/pom.xml
index 8881210b6..ddd0b9574 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
io.ebean
ebean-querybean
- 12.8.3-SNAPSHOT
+ 12.8.3
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 4b957878f..545078f3c 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.8.3-SNAPSHOT
+ 12.8.3
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.8.3-SNAPSHOT
+ 12.8.3
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.8.3-SNAPSHOT
+ 12.8.3
test
diff --git a/pom.xml b/pom.xml
index 10f7d260d..61571ff85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.8.3-SNAPSHOT
+ 12.8.3
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.8.3
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index 5d6d29dc6..996feff79 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3-SNAPSHOT
+ 12.8.3
querybean generator
From 5e893dd2ade2aac9c74ecb7234750bb859401fed Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Mon, 19 Apr 2021 21:40:16 +1200
Subject: [PATCH 037/111] [maven-release-plugin] prepare for next development
iteration
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 1dfb09ea5..380438cc2 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index d02ceb219..590680c8a 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.3
+ ebean-parent-12.8.0
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 01aff5126..aaa2b5961 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-api
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-core-type
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-ddl-generator
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-externalmapping-xml
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-autotune
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-querybean
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
querybean-generator
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
io.ebean
kotlin-querybean-generator
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
io.ebean
ebean-test
- 12.8.3
+ 12.8.4-SNAPSHOT
test
io.ebean
ebean-postgis
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-redis
- 12.8.3
+ 12.8.4-SNAPSHOT
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index 1bee819fd..04497471c 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.8.3
+ 12.8.4-SNAPSHOT
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index c395097e6..dbde9f167 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.3
+ ebean-parent-12.8.0
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-core-type
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.8.3
+ 12.8.4-SNAPSHOT
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 959230160..f94924830 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index 3031bebb8..079eebec9 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index 311a6f776..bcf9f10ff 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.3
+ ebean-parent-12.8.0
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.8.3
+ 12.8.4-SNAPSHOT
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
test
io.ebean
ebean-ddl-generator
- 12.8.3
+ 12.8.4-SNAPSHOT
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index a254289cf..4e1b6063b 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.8.3
+ 12.8.4-SNAPSHOT
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index 252e28c54..ff6dd8754 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.8.3
+ 12.8.4-SNAPSHOT
test
io.ebean
querybean-generator
- 12.8.3
+ 12.8.4-SNAPSHOT
test
io.ebean
ebean-test
- 12.8.3
+ 12.8.4-SNAPSHOT
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index c238e7c7d..01062abf1 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
io.ebean
ebean-querybean
- 12.8.3
+ 12.8.4-SNAPSHOT
test
io.ebean
querybean-generator
- 12.8.3
+ 12.8.4-SNAPSHOT
test
io.ebean
ebean-test
- 12.8.3
+ 12.8.4-SNAPSHOT
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index 9b13477da..c3ed1f57f 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
provided
io.ebean
ebean-ddl-generator
- 12.8.3
+ 12.8.4-SNAPSHOT
diff --git a/ebean/pom.xml b/ebean/pom.xml
index ddd0b9574..ba312953f 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
io.ebean
ebean-querybean
- 12.8.3
+ 12.8.4-SNAPSHOT
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 545078f3c..a556671bb 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.8.3
+ 12.8.4-SNAPSHOT
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.8.3
+ 12.8.4-SNAPSHOT
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.8.3
+ 12.8.4-SNAPSHOT
test
diff --git a/pom.xml b/pom.xml
index 61571ff85..fb82113fa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.8.3
+ 12.8.4-SNAPSHOT
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.3
+ ebean-parent-12.8.0
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index 996feff79..1ea632096 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.3
+ 12.8.4-SNAPSHOT
querybean generator
From c60077174ed01d4babc0049a0beecc4ae70d0415 Mon Sep 17 00:00:00 2001
From: Robin Bygrave
Date: Tue, 20 Apr 2021 15:14:20 +1200
Subject: [PATCH 038/111] Tidy use of StringHelper replace() in BeanProperty,
BaseTableDdl
---
.../java/io/ebeaninternal/server/deploy/BeanProperty.java | 8 +++-----
.../dbmigration/ddlgeneration/platform/BaseTableDdl.java | 2 +-
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
index 270415a22..d96a3d850 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
@@ -56,8 +56,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import static io.ebean.util.StringHelper.replace;
-
/**
* Description of a property of a bean. Includes its deployment information such
* as database column mapping information.
@@ -357,12 +355,12 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
private String tableAliasIntern(BeanDescriptor> descriptor, String s, boolean dbEncrypted, String dbColumn) {
if (descriptor != null) {
- s = replace(s, "${ta}.", "${}");
- s = replace(s, "${ta}", "${}");
+ s = s.replace("${ta}.", "${}");
+ s = s.replace("${ta}", "${}");
if (dbEncrypted) {
s = dbEncryptFunction.getDecryptSql(s);
String namedParam = ":encryptkey_" + descriptor.getBaseTable() + "___" + dbColumn;
- s = replace(s, "?", namedParam);
+ s = s.replace("?", namedParam);
}
}
return InternString.intern(s);
diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java
index 41e91274e..0e80c2676 100644
--- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java
+++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/BaseTableDdl.java
@@ -150,7 +150,7 @@ public class BaseTableDdl implements TableDdl {
buffer.append("-- NOTE: table has @History - special migration may be necessary").newLine();
}
for (String ddlScript : before) {
- buffer.appendStatement(translate(ddlScript, tableName, columnName, this.defaultValue));
+ buffer.appendStatement(translate(ddlScript, tableName, columnName, defaultValue));
}
}
From 4fb3b9cddc3c1d052c6509249011819df1c12f4b Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Tue, 20 Apr 2021 22:13:45 +1200
Subject: [PATCH 039/111] Tidy use of StringHelper replace() in BeanProperty,
BaseTableDdl
---
.../main/java/io/ebeaninternal/server/deploy/BeanProperty.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
index d96a3d850..8793942b6 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanProperty.java
@@ -354,7 +354,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
}
private String tableAliasIntern(BeanDescriptor> descriptor, String s, boolean dbEncrypted, String dbColumn) {
- if (descriptor != null) {
+ if (s != null && descriptor != null) {
s = s.replace("${ta}.", "${}");
s = s.replace("${ta}", "${}");
if (dbEncrypted) {
From 42fc41975907274f44bb58bff35f1b1f573f8054 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Tue, 20 Apr 2021 22:23:33 +1200
Subject: [PATCH 040/111] #2221 - ebean-redis: bump jedis dependency to 3.6.0
---
ebean-redis/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index 01062abf1..573fbcf3b 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -16,7 +16,7 @@
redis.clients
jedis
- 3.5.2
+ 3.6.0
From 74c7268d2fc73e439cc661beb6d9312d7758bea2 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Wed, 21 Apr 2021 18:57:03 +1200
Subject: [PATCH 041/111] Change such that filterMany can be included in the
main query.
That is, currently a filterMany automatically marks that path as a fetchQuery path. This change turns that off and the filterMany path and predicates can then be included in the main query.
This is better for performance (to include the filterMany path in with the main query) when the query is a findEach and looking to return a large number of results.
---
.../io/ebeaninternal/api/SpiExpression.java | 5 ++
.../ebeaninternal/api/SpiExpressionList.java | 5 ++
.../server/core/OrmQueryRequest.java | 4 +-
.../server/expression/AbstractExpression.java | 7 ++-
.../expression/BetweenPropertyExpression.java | 10 +++-
.../expression/DefaultExampleExpression.java | 7 +++
.../expression/DefaultExpressionList.java | 7 +++
.../expression/ExistsQueryExpression.java | 5 ++
.../server/expression/IdExpression.java | 5 ++
.../server/expression/JunctionExpression.java | 5 ++
.../server/expression/LogicExpression.java | 6 +++
.../NestedPathWrapperExpression.java | 5 ++
.../expression/NonPrepareExpression.java | 5 ++
.../server/expression/NoopExpression.java | 5 ++
.../server/expression/NotExpression.java | 5 ++
.../server/querydefn/DefaultOrmQuery.java | 1 +
.../server/querydefn/OrmQueryDetail.java | 45 +++++------------
.../server/querydefn/OrmQueryProperties.java | 22 ++++++--
...faultServer_createOrmQueryRequestTest.java | 36 ++++++++++++-
.../org/tests/query/TestQueryFilterMany.java | 50 +++++++++++--------
20 files changed, 179 insertions(+), 61 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java
index cad22c50a..007e9f29f 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpression.java
@@ -105,4 +105,9 @@ public interface SpiExpression extends Expression {
* Check for match to a natural key query returning false if it doesn't match.
*/
boolean naturalKey(NaturalKeyQueryData> data);
+
+ /**
+ * Apply property prefix when filterMany expressions included into main query.
+ */
+ void prefixProperty(String path);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionList.java b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionList.java
index 3cf5c2e64..c4764b30f 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionList.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/SpiExpressionList.java
@@ -43,4 +43,9 @@ public interface SpiExpressionList extends ExpressionList, SpiExpression {
default void applyRowLimits(SpiQuery> query) {
// do nothing by default
}
+
+ /**
+ * Apply property prefix when filterMany expressions included in main query.
+ */
+ void prefixProperty(String path);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java
index 3ec5deac7..5548c88e3 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/OrmQueryRequest.java
@@ -219,10 +219,10 @@ public final class OrmQueryRequest extends BeanRequest implements SpiOrmQuery
*/
@Override
public void prepareQuery() {
+ secondaryQueries = query.convertJoins();
beanDescriptor.prepareQuery(query);
adapterPreQuery();
- this.secondaryQueries = query.convertJoins();
- this.queryPlanKey = query.prepare(this);
+ queryPlanKey = query.prepare(this);
}
public boolean isNativeSql() {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java
index 0ae5cd6fc..c3090e38f 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/AbstractExpression.java
@@ -16,12 +16,17 @@ import io.ebeaninternal.api.NaturalKeyQueryData;
*/
public abstract class AbstractExpression implements SpiExpression {
- protected final String propName;
+ protected String propName;
protected AbstractExpression(String propName) {
this.propName = propName;
}
+ @Override
+ public void prefixProperty(String path) {
+ this.propName = path + "." + propName;
+ }
+
@Override
public boolean naturalKey(NaturalKeyQueryData> data) {
// by default can't use naturalKey cache
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java
index 798908335..a50ec888f 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/BetweenPropertyExpression.java
@@ -17,8 +17,8 @@ class BetweenPropertyExpression extends NonPrepareExpression {
private static final String BETWEEN = " between ";
- private final String lowProperty;
- private final String highProperty;
+ private String lowProperty;
+ private String highProperty;
private final Object value;
BetweenPropertyExpression(String lowProperty, String highProperty, Object value) {
@@ -27,6 +27,12 @@ class BetweenPropertyExpression extends NonPrepareExpression {
this.value = value;
}
+ @Override
+ public void prefixProperty(String path) {
+ this.lowProperty = path + "." + lowProperty;
+ this.highProperty = path + "." + highProperty;
+ }
+
protected String name(String propName) {
return propName;
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java
index c6fa5d087..aade99f5a 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExampleExpression.java
@@ -88,6 +88,13 @@ public class DefaultExampleExpression implements SpiExpression, ExampleExpressio
}
}
+ @Override
+ public void prefixProperty(String path) {
+ for (SpiExpression exp : list) {
+ exp.prefixProperty(path);
+ }
+ }
+
@Override
public boolean naturalKey(NaturalKeyQueryData> data) {
// can't use naturalKey cache
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java
index c034b2992..ab80ae9e5 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/DefaultExpressionList.java
@@ -126,6 +126,13 @@ public class DefaultExpressionList implements SpiExpressionList {
}
}
+ @Override
+ public void prefixProperty(String path) {
+ for (SpiExpression exp : list) {
+ exp.prefixProperty(path);
+ }
+ }
+
@Override
public Junction toJunction() {
return new JunctionExpression<>(Junction.Type.FILTER, this);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java
index 8918bd05d..32ae2bccc 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/ExistsQueryExpression.java
@@ -36,6 +36,11 @@ class ExistsQueryExpression implements SpiExpression, UnsupportedDocStoreExpress
this.subQuery = null;
}
+ @Override
+ public void prefixProperty(String path) {
+ // do nothing
+ }
+
@Override
public boolean naturalKey(NaturalKeyQueryData> data) {
// can't use naturalKey cache
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java
index 12910fb37..b5280b868 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/IdExpression.java
@@ -19,6 +19,11 @@ class IdExpression extends NonPrepareExpression implements SpiExpression {
this.value = value;
}
+ @Override
+ public void prefixProperty(String path) {
+ throw new IllegalStateException("Not allowed?");
+ }
+
@Override
public void writeDocQuery(DocQueryContext context) throws IOException {
context.writeId(value);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java
index f048f1163..0aae30886 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/JunctionExpression.java
@@ -66,6 +66,11 @@ class JunctionExpression implements SpiJunction, SpiExpression, Expression
this.exprList = exprList;
}
+ @Override
+ public void prefixProperty(String path) {
+ exprList.prefixProperty(path);
+ }
+
@Override
public boolean naturalKey(NaturalKeyQueryData> data) {
// can't use naturalKey cache
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java
index 0fa0d9b37..482aac6e8 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/LogicExpression.java
@@ -57,6 +57,12 @@ abstract class LogicExpression implements SpiExpression {
this.expTwo = (SpiExpression) expTwo;
}
+ @Override
+ public void prefixProperty(String path) {
+ expOne.prefixProperty(path);
+ expTwo.prefixProperty(path);
+ }
+
@Override
public boolean naturalKey(NaturalKeyQueryData> data) {
// can't use naturalKey cache
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java
index c7f5d193e..77f46828b 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NestedPathWrapperExpression.java
@@ -24,6 +24,11 @@ class NestedPathWrapperExpression implements SpiExpression {
this.delegate = delegate;
}
+ @Override
+ public void prefixProperty(String path) {
+ // do nothing
+ }
+
@Override
public boolean naturalKey(NaturalKeyQueryData> data) {
// can't use naturalKey cache
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NonPrepareExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NonPrepareExpression.java
index 675e641ee..e384bbd1e 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NonPrepareExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NonPrepareExpression.java
@@ -9,6 +9,11 @@ import io.ebeaninternal.api.NaturalKeyQueryData;
*/
abstract class NonPrepareExpression implements SpiExpression {
+ @Override
+ public void prefixProperty(String path) {
+ // do nothing
+ }
+
@Override
public boolean naturalKey(NaturalKeyQueryData> data) {
// can't use naturalKey cache
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java
index c95c8585b..28c9e3c78 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NoopExpression.java
@@ -17,6 +17,11 @@ class NoopExpression implements SpiExpression {
protected static final NoopExpression INSTANCE = new NoopExpression();
+ @Override
+ public void prefixProperty(String path) {
+ // do nothing
+ }
+
@Override
public boolean naturalKey(NaturalKeyQueryData> data) {
// can't use naturalKey cache
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java
index 29535cd95..60ade47b0 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/expression/NotExpression.java
@@ -22,6 +22,11 @@ final class NotExpression implements SpiExpression {
this.exp = (SpiExpression) exp;
}
+ @Override
+ public void prefixProperty(String path) {
+ exp.prefixProperty(path);
+ }
+
@Override
public boolean naturalKey(NaturalKeyQueryData> data) {
// can't use naturalKey cache
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
index 867e16dfa..71fe9ff68 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultOrmQuery.java
@@ -1238,6 +1238,7 @@ public class DefaultOrmQuery implements SpiQuery {
* Prepare the expressions (compile sub-queries etc).
*/
private void prepareExpressions(BeanQueryRequest> request) {
+ detail.prepareExpressions(request);
if (whereExpressions != null) {
whereExpressions.prepareExpression(request);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
index 6f96fbbea..6646746eb 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
@@ -1,6 +1,7 @@
package io.ebeaninternal.server.querydefn;
import io.ebean.FetchConfig;
+import io.ebean.event.BeanQueryRequest;
import io.ebean.util.SplitName;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.deploy.BeanPropertyAssoc;
@@ -9,25 +10,16 @@ import io.ebeaninternal.server.el.ElPropertyValue;
import javax.persistence.PersistenceException;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* Represents the internal structure of an Object Relational query.
*
* Holds the select() and join() details of a ORM query.
- *
*
* It is worth noting that for AutoTune a "tuned fetch info" builds an instance of OrmQueryDetail.
* Tuning a query is a matter of replacing an instance of this class with one that has been tuned
* with select() and join() set.
- *
*/
public class OrmQueryDetail implements Serializable {
@@ -81,7 +73,6 @@ public class OrmQueryDetail implements Serializable {
* Return true if equal in terms of autoTune (select and fetch without property ordering).
*/
public boolean isAutoTuneEqual(OrmQueryDetail otherDetail) {
-
if (!isSameByAutoTune(baseProps, otherDetail.baseProps)) {
return false;
}
@@ -175,9 +166,7 @@ public class OrmQueryDetail implements Serializable {
}
private List removeSecondaryQueries(boolean lazyQuery) {
-
ArrayList matchingPaths = new ArrayList<>(2);
-
for (OrmQueryProperties chunk : fetchPaths.values()) {
boolean match = lazyQuery ? chunk.isLazyFetch() : chunk.isQueryFetch();
if (match) {
@@ -191,7 +180,6 @@ public class OrmQueryDetail implements Serializable {
// sort into depth order to remove
Collections.sort(matchingPaths);
-
// the list of secondary queries
ArrayList props = new ArrayList<>();
@@ -225,14 +213,11 @@ public class OrmQueryDetail implements Serializable {
OrmQueryProperties chunk = getChunk(split[0], true);
chunk.addSecondaryQueryJoin(split[1]);
}
-
return props;
}
boolean tuneFetchProperties(OrmQueryDetail tunedDetail) {
-
boolean tuned = false;
-
OrmQueryProperties tunedRoot = tunedDetail.getChunk(null, false);
if (tunedRoot != null) {
tuned = true;
@@ -257,10 +242,7 @@ public class OrmQueryDetail implements Serializable {
}
/**
- * Remove all joins and properties.
- *
- * Typically for the row count query.
- *
+ * Remove all joins and properties. Typically for the row count query.
*/
public void clear() {
fetchPaths.clear();
@@ -306,7 +288,6 @@ public class OrmQueryDetail implements Serializable {
}
private void sortFetchPaths(BeanDescriptor> d, boolean addIds) {
-
if (!fetchPaths.isEmpty()) {
LinkedHashMap sorted = new LinkedHashMap<>();
for (OrmQueryProperties p : fetchPaths.values()) {
@@ -317,7 +298,6 @@ public class OrmQueryDetail implements Serializable {
}
private void sortFetchPaths(BeanDescriptor> d, OrmQueryProperties p, LinkedHashMap sorted, boolean addId) {
-
String path = p.getPath();
if (!sorted.containsKey(path)) {
String parentPath = p.getParentPath();
@@ -339,7 +319,6 @@ public class OrmQueryDetail implements Serializable {
parentProp = new OrmQueryProperties(parentPath, Collections.emptySet());
}
}
-
sortFetchPaths(d, parentProp, sorted, addId);
sorted.put(path, p);
}
@@ -350,14 +329,12 @@ public class OrmQueryDetail implements Serializable {
* Mark 'fetch joins' to 'many' properties over to 'query joins' where needed.
*/
void markQueryJoins(BeanDescriptor> beanDescriptor, String lazyLoadManyPath, boolean allowOne, boolean addIds) {
-
if (fetchPaths.isEmpty()) {
return;
}
// the name of the many fetch property if there is one
String manyFetchProperty = null;
-
// flag that is set once the many fetch property is chosen
boolean fetchJoinFirstMany = allowOne;
@@ -375,6 +352,7 @@ public class OrmQueryDetail implements Serializable {
// letting the first one remain a 'fetch join'
fetchJoinFirstMany = false;
manyFetchProperty = pair.getPath();
+ chunk.filterManyInline();
} else {
// convert this one over to a 'query join'
chunk.markForQueryJoin();
@@ -388,7 +366,6 @@ public class OrmQueryDetail implements Serializable {
* Sort the fetch entries taking into account fetchPreference on the path.
*/
private List sortByFetchPreference(BeanDescriptor> desc) {
-
List entries = new ArrayList<>(fetchPaths.size());
int idx = 0;
for (Map.Entry entry : fetchPaths.entrySet()) {
@@ -452,11 +429,9 @@ public class OrmQueryDetail implements Serializable {
*
*/
public void setDefaultSelectClause(BeanDescriptor> desc) {
-
if (desc.hasDefaultSelectClause() && !hasSelectClause()) {
baseProps = new OrmQueryProperties(null, desc.getDefaultSelectClause());
}
-
for (OrmQueryProperties joinProps : fetchPaths.values()) {
if (!joinProps.hasSelectClause()) {
BeanDescriptor> assocDesc = desc.getBeanDescriptor(joinProps.getPath());
@@ -506,7 +481,6 @@ public class OrmQueryDetail implements Serializable {
props = new OrmQueryProperties(path);
fetch(props);
return props;
-
} else {
return props;
}
@@ -516,9 +490,7 @@ public class OrmQueryDetail implements Serializable {
* Return true if the fetch path is included.
*/
public boolean includesPath(String path) {
-
OrmQueryProperties chunk = fetchPaths.get(path);
-
// may not have fetch properties if just +cache etc
return chunk != null && !chunk.isCache();
}
@@ -537,6 +509,15 @@ public class OrmQueryDetail implements Serializable {
return fetchPaths.entrySet();
}
+ /**
+ * Prepare filterMany expressions that are being included into the main query.
+ */
+ public void prepareExpressions(BeanQueryRequest> request) {
+ for (OrmQueryProperties value : fetchPaths.values()) {
+ value.prepareExpressions(request);
+ }
+ }
+
private static class FetchEntry implements Comparable {
private final int index;
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
index 466bb3eb9..0a8b51465 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryProperties.java
@@ -4,6 +4,7 @@ import io.ebean.ExpressionFactory;
import io.ebean.FetchConfig;
import io.ebean.OrderBy;
import io.ebean.Query;
+import io.ebean.event.BeanQueryRequest;
import io.ebean.util.SplitName;
import io.ebeaninternal.api.SpiExpression;
import io.ebeaninternal.api.SpiExpressionFactory;
@@ -178,8 +179,6 @@ public class OrmQueryProperties implements Serializable {
SpiExpressionFactory queryEf = (SpiExpressionFactory) rootQuery.getExpressionFactory();
ExpressionFactory filterEf = queryEf.createExpressionFactory();// exprPath);
filterMany = new FilterExpressionList(exprPath, filterEf, rootQuery);
- // by default we need to make this a 'query join' now
- markForQueryJoin = true;
}
return filterMany;
}
@@ -194,6 +193,24 @@ public class OrmQueryProperties implements Serializable {
return filterMany.trimPath(trimPath);
}
+ /**
+ * Adjust filterMany expressions for inclusion in main query.
+ */
+ public void filterManyInline() {
+ if (filterMany != null){
+ filterMany.prefixProperty(path);
+ }
+ }
+
+ /**
+ * Prepare filterMany expressions for query plan key.
+ */
+ public void prepareExpressions(BeanQueryRequest> request) {
+ if (filterMany != null) {
+ filterMany.prepareExpression(request);
+ }
+ }
+
/**
* Return the filterMany expression list (can be null).
*/
@@ -206,7 +223,6 @@ public class OrmQueryProperties implements Serializable {
*/
public void setFilterMany(SpiExpressionList> filterMany) {
this.filterMany = filterMany;
- this.markForQueryJoin = true;
}
/**
diff --git a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java b/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java
index 12c731115..1a5484f16 100644
--- a/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java
+++ b/ebean-core/src/test/java/io/ebeaninternal/server/core/DefaultServer_createOrmQueryRequestTest.java
@@ -288,7 +288,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
}
@Test
- public void test_removeJoinToMany_when_filterMany() {
+ public void test_filterMany_included() {
Query query = Ebean.find(Order.class)
.fetch("details")
@@ -301,6 +301,40 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
OrmQueryRequest queryRequest = queryRequest(query);
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
+ assertThat(detail.getFetchPaths()).containsExactly("details", "details.product", "customer");
+ }
+
+ @Test
+ public void test_filterMany_excludedByOrdering() {
+
+ Query query = Ebean.find(Order.class)
+ .fetch("customer")
+ .fetch("customer.contacts")
+ .fetch("details")
+ .fetch("details.product")
+ .filterMany("details").eq("orderQuantity", 10)
+ .query();
+
+ OrmQueryRequest queryRequest = queryRequest(query);
+ OrmQueryDetail detail = queryRequest.getQuery().getDetail();
+
+ assertThat(detail.getFetchPaths()).containsExactly("customer", "customer.contacts");
+ }
+
+ @Test
+ public void test_filterMany_excludedExplicitly() {
+
+ Query query = Ebean.find(Order.class)
+ .fetchQuery("details")
+ .fetch("details.product")
+ .fetch("customer")
+ .fetch("customer.contacts")
+ .filterMany("details").eq("orderQuantity", 10)
+ .query();
+
+ OrmQueryRequest queryRequest = queryRequest(query);
+ OrmQueryDetail detail = queryRequest.getQuery().getDetail();
+
assertThat(detail.getFetchPaths()).containsExactly("customer", "customer.contacts");
}
diff --git a/ebean-core/src/test/java/org/tests/query/TestQueryFilterMany.java b/ebean-core/src/test/java/org/tests/query/TestQueryFilterMany.java
index 976dac580..be58fb8c4 100644
--- a/ebean-core/src/test/java/org/tests/query/TestQueryFilterMany.java
+++ b/ebean-core/src/test/java/org/tests/query/TestQueryFilterMany.java
@@ -172,7 +172,6 @@ public class TestQueryFilterMany extends BaseTestCase {
LoggedSqlCollector.start();
Query query = Ebean.find(Customer.class)
- .fetch("orders")
.filterMany("orders").raw("1=0")
.where().isNotEmpty("orders")
.query();
@@ -183,12 +182,10 @@ public class TestQueryFilterMany extends BaseTestCase {
}
List sqlList = LoggedSqlCollector.stop();
- assertEquals(2, sqlList.size());
- assertThat(sqlList.get(0)).contains("where exists (select 1 from o_order x where x.kcustomer_id = t0.id)");
- assertThat(sqlList.get(1)).contains("and 1=0");
+ assertEquals(1, sqlList.size());
+ assertThat(sqlList.get(0)).contains("from o_customer t0 left join o_order t1 on t1.kcustomer_id = t0.id and t1.order_date is not null left join o_customer t2 on t2.id = t1.kcustomer_id where exists (select 1 from o_order x where x.kcustomer_id = t0.id) and 1=0 order by t0.id");
}
-
@Test
public void test_filterMany_in_findCount() {
@@ -212,7 +209,6 @@ public class TestQueryFilterMany extends BaseTestCase {
public void test_filterMany_copy_findList() {
ResetBasicData.reset();
-
LoggedSqlCollector.start();
Query query = Ebean.find(Customer.class)
@@ -222,17 +218,35 @@ public class TestQueryFilterMany extends BaseTestCase {
query.copy().findList();
+ List sqlList = LoggedSqlCollector.stop();
+ assertEquals(1, sqlList.size());
+ assertThat(sqlList.get(0)).contains("from o_customer t0 left join o_order t1 on t1.kcustomer_id = t0.id and t1.order_date is not null left join o_customer t2 on t2.id = t1.kcustomer_id where t1.status in (?) order by t0.id");
+ }
+
+ @Test
+ public void test_filterMany_fetchQuery() {
+
+ ResetBasicData.reset();
+ LoggedSqlCollector.start();
+
+ Query query = Ebean.find(Customer.class)
+ .fetchQuery("orders") // explicitly fetch orders separately
+ .filterMany("orders").in("status", Order.Status.NEW)
+ .order().asc("id");
+
+ query.findList();
+
List sqlList = LoggedSqlCollector.stop();
assertEquals(2, sqlList.size());
assertThat(sqlList.get(0)).contains("from o_customer t0");
- assertThat(sqlList.get(1)).contains("from o_order t0 join o_customer t1");
+ assertThat(sqlList.get(1)).contains("from o_order t0 join o_customer t1 on t1.id = t0.kcustomer_id where t0.order_date is not null and (t0.kcustomer_id) in ");
+ assertThat(sqlList.get(1)).contains(" and t0.status in ");
}
@Test
public void testDisjunction() {
ResetBasicData.reset();
-
LoggedSqlCollector.start();
Ebean.find(Customer.class)
@@ -243,8 +257,8 @@ public class TestQueryFilterMany extends BaseTestCase {
.findList();
List sql = LoggedSqlCollector.stop();
- assertEquals(2, sql.size());
- assertSql(sql.get(1)).contains("and (t0.status = ? or t0.order_date = ?");
+ assertEquals(1, sql.size());
+ assertSql(sql.get(0)).contains(" from o_customer t0 left join o_order t1 on t1.kcustomer_id = t0.id and t1.order_date is not null left join o_customer t2 on t2.id = t1.kcustomer_id where (t1.status = ? or t1.order_date = ?) order by t0.id");
}
@Test
@@ -259,12 +273,10 @@ public class TestQueryFilterMany extends BaseTestCase {
List sql = LoggedSqlCollector.stop();
- assertThat(sql).hasSize(3);
- assertSql(sql.get(0)).contains(" from o_customer t0; --bind()");
- platformAssertIn(sql.get(1), " from contact t0 where (t0.customer_id)");
- assertSql(sql.get(1)).contains(" and t0.first_name is not null");
- platformAssertIn(sql.get(2), " from contact_note t0 where (t0.contact_id)");
- assertSql(sql.get(2)).contains(" and lower(t0.title) like");
+ assertThat(sql).hasSize(2);
+ assertSql(sql.get(0)).contains(" from o_customer t0 left join contact t1 on t1.customer_id = t0.id where t1.first_name is not null order by t0.id; --bind()");
+ platformAssertIn(sql.get(1), " from contact_note t0 where (t0.contact_id)");
+ assertSql(sql.get(1)).contains(" and lower(t0.title) like");
}
@Test
@@ -280,9 +292,7 @@ public class TestQueryFilterMany extends BaseTestCase {
List sql = LoggedSqlCollector.stop();
- assertThat(sql).hasSize(2);
- assertSql(sql.get(0)).contains(" from o_customer t0");
- assertSql(sql.get(1)).contains("from contact t0 where ");
- assertSql(sql.get(1)).contains("and (t0.first_name is not null and lower(t0.email) like ?");
+ assertThat(sql).hasSize(1);
+ assertSql(sql.get(0)).contains(" from o_customer t0 left join contact t1 on t1.customer_id = t0.id where (t1.first_name is not null and lower(t1.email) like ? escape'|' ) order by t0.id; --bind(rob%)");
}
}
From d6fdb4ee34129f4b98b35686b822c3c4154d77b6 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 26 Apr 2021 20:37:55 +0000
Subject: [PATCH 042/111] Bump commons-io from 2.5 to 2.7 in /ebean-core
Bumps commons-io from 2.5 to 2.7.
Signed-off-by: dependabot[bot]
---
ebean-core/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index dbde9f167..13732d513 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -282,7 +282,7 @@
commons-io
commons-io
- 2.5
+ 2.7
test
From ad52711fe172e70d5ab2f649f163399f2dc4ce62 Mon Sep 17 00:00:00 2001
From: Brian Payne
Date: Tue, 11 May 2021 08:52:08 -0700
Subject: [PATCH 043/111] Add test demonstrating soft-delete bug with optional
relationship
---
.../org/tests/model/softdelete/ESoftDelX.java | 54 +++++++++++++++++++
.../org/tests/model/softdelete/ESoftDelY.java | 53 ++++++++++++++++++
.../org/tests/model/softdelete/ESoftDelZ.java | 43 +++++++++++++++
.../TestSoftDeleteOptionalRelationship.java | 31 +++++++++++
4 files changed, 181 insertions(+)
create mode 100644 ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelX.java
create mode 100644 ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelY.java
create mode 100644 ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelZ.java
diff --git a/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelX.java b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelX.java
new file mode 100644
index 000000000..fbc3f9964
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelX.java
@@ -0,0 +1,54 @@
+package org.tests.model.softdelete;
+
+import io.ebean.annotation.SoftDelete;
+
+import javax.persistence.*;
+import java.util.UUID;
+
+@Entity
+public class ESoftDelX {
+
+ @Id
+ private UUID id;
+
+ @OneToOne
+ private ESoftDelY y;
+
+ @ManyToOne
+ private ESoftDelZ organization;
+
+ @SoftDelete
+ boolean deleted;
+
+ public UUID getId() {
+ return id;
+ }
+
+ public void setId(UUID id) {
+ this.id = id;
+ }
+
+ public ESoftDelY getY() {
+ return y;
+ }
+
+ public void setY(ESoftDelY y) {
+ this.y = y;
+ }
+
+ public ESoftDelZ getOrganization() {
+ return organization;
+ }
+
+ public void setOrganization(ESoftDelZ organization) {
+ this.organization = organization;
+ }
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+
+ public void setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ }
+}
diff --git a/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelY.java b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelY.java
new file mode 100644
index 000000000..a65cc75c1
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelY.java
@@ -0,0 +1,53 @@
+package org.tests.model.softdelete;
+
+import io.ebean.annotation.SoftDelete;
+
+import javax.persistence.*;
+
+@Entity
+public class ESoftDelY {
+
+ @Id
+ private Long id;
+
+ @ManyToOne
+ private ESoftDelZ organization;
+
+ @OneToOne(mappedBy = "y")
+ private ESoftDelX x;
+
+ @SoftDelete
+ boolean deleted;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public ESoftDelZ getOrganization() {
+ return organization;
+ }
+
+ public void setOrganization(ESoftDelZ organization) {
+ this.organization = organization;
+ }
+
+ public ESoftDelX getX() {
+ return x;
+ }
+
+ public void setX(ESoftDelX x) {
+ this.x = x;
+ }
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+
+ public void setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ }
+}
diff --git a/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelZ.java b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelZ.java
new file mode 100644
index 000000000..5ce11c175
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/model/softdelete/ESoftDelZ.java
@@ -0,0 +1,43 @@
+package org.tests.model.softdelete;
+
+import io.ebean.annotation.SoftDelete;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import java.util.UUID;
+
+@Entity
+public class ESoftDelZ {
+
+ @Id
+ private Long id;
+
+ @SoftDelete
+ private boolean deleted;
+
+ private UUID uuid;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+
+ public void setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ }
+
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+}
diff --git a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java
index fc925f62c..2488060d4 100644
--- a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java
+++ b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java
@@ -1,9 +1,15 @@
package org.tests.softdelete;
import io.ebean.BaseTestCase;
+import io.ebean.DB;
import io.ebean.Ebean;
import org.tests.model.softdelete.ESoftDelMid;
+import io.ebean.Finder;
import org.junit.Test;
+import org.tests.model.softdelete.ESoftDelY;
+import org.tests.model.softdelete.ESoftDelZ;
+
+import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
@@ -24,5 +30,30 @@ public class TestSoftDeleteOptionalRelationship extends BaseTestCase {
assertThat(bean.getTop()).isNull();
}
+ @Test
+ public void testFindNullWhenMultiple() {
+ UUID uuid = UUID.randomUUID();
+ {
+ ESoftDelZ z = new ESoftDelZ();
+ z.setUuid(uuid);
+ DB.save(z);
+
+ ESoftDelY y = new ESoftDelY();
+ y.setOrganization(z);
+ y.setX(null);
+ DB.save(y);
+ }
+
+ Finder finder = new Finder<>(ESoftDelY.class);
+ ESoftDelY bean = finder
+ .query()
+ .where()
+ .eq("organization.uuid", uuid)
+ .isNull("x")
+ .findOne();
+
+ assertThat(bean).isNotNull();
+ }
+
}
From 66f7f69ec70bc301d8effb18f01185b817064fdd Mon Sep 17 00:00:00 2001
From: Brian Payne
Date: Wed, 12 May 2021 09:24:33 -0700
Subject: [PATCH 044/111] Fixed bug with soft-delete on one-to-one exported
---
.../server/query/SqlTreeNodeExtraJoin.java | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java
index 074457a30..7238224d7 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java
@@ -5,6 +5,7 @@ import io.ebean.bean.EntityBean;
import io.ebean.core.type.ScalarType;
import io.ebean.util.SplitName;
import io.ebeaninternal.api.SpiQuery;
+import io.ebeaninternal.server.deploy.BeanPropertyAssocOne;
import io.ebeaninternal.server.deploy.DbReadContext;
import io.ebeaninternal.server.deploy.DbSqlContext;
import io.ebeaninternal.server.deploy.TableJoin;
@@ -130,11 +131,19 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode {
}
}
+ boolean oneToOneExported = false;
+ if (assocBeanProperty instanceof BeanPropertyAssocOne) {
+ BeanPropertyAssocOne> oneToOneProp = (BeanPropertyAssocOne>) assocBeanProperty;
+ if (oneToOneProp.isOneToOneExported()) {
+ oneToOneExported = true;
+ }
+ }
+
if (pathContainsMany) {
// "promote" to left join as the path contains a many
joinType = SqlJoinType.OUTER;
}
- if (!manyToMany) {
+ if (!manyToMany && !oneToOneExported) {
if (assocBeanProperty.isFormula()) {
// add joins for formula beans
assocBeanProperty.appendFrom(ctx, joinType);
From eb00690b3034b970d4e7a1778d61eb0c305c82aa Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Thu, 20 May 2021 14:09:22 +1200
Subject: [PATCH 045/111] #2231 - Change OrderBy to not be final to support
mocking via Mockito
---
ebean-api/src/main/java/io/ebean/OrderBy.java | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/ebean-api/src/main/java/io/ebean/OrderBy.java b/ebean-api/src/main/java/io/ebean/OrderBy.java
index 820a76314..8b39fc19e 100644
--- a/ebean-api/src/main/java/io/ebean/OrderBy.java
+++ b/ebean-api/src/main/java/io/ebean/OrderBy.java
@@ -16,7 +16,7 @@ import java.util.Objects;
* on the Query object.
*
*/
-public final class OrderBy implements Serializable {
+public class OrderBy implements Serializable {
private static final long serialVersionUID = 9157089257745730539L;
@@ -69,7 +69,6 @@ public final class OrderBy implements Serializable {
* Add a property with ascending order to this OrderBy.
*/
public Query asc(String propertyName) {
-
list.add(new Property(propertyName, true));
return query;
}
@@ -98,7 +97,6 @@ public final class OrderBy implements Serializable {
return query;
}
-
/**
* Return true if the property is known to be contained in the order by clause.
*/
@@ -207,7 +205,6 @@ public final class OrderBy implements Serializable {
if (!(obj instanceof OrderBy>)) {
return false;
}
-
OrderBy> e = (OrderBy>) obj;
return e.list.equals(list);
}
@@ -249,7 +246,7 @@ public final class OrderBy implements Serializable {
/**
* A property and its ascending descending order.
*/
- public static final class Property implements Serializable {
+ public static class Property implements Serializable {
private static final long serialVersionUID = 1546009780322478077L;
@@ -415,13 +412,10 @@ public final class OrderBy implements Serializable {
}
private void parse(String orderByClause) {
-
if (orderByClause == null) {
return;
}
-
- String[] chunks = orderByClause.split(",");
- for (String chunk : chunks) {
+ for (String chunk : orderByClause.split(",")) {
Property p = parseProperty(chunk);
if (p != null) {
list.add(p);
@@ -467,8 +461,7 @@ public final class OrderBy implements Serializable {
if (s.startsWith("desc")) {
return false;
}
- String m = "Expecting [" + s + "] to be asc or desc?";
- throw new RuntimeException(m);
+ throw new RuntimeException("Expecting [" + s + "] to be asc or desc?");
}
private boolean isEmptyString(String s) {
From b17593ba3cbf4a2c70967fbf0a93568607d10961 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Thu, 20 May 2021 21:44:07 +1200
Subject: [PATCH 046/111] No effective change - tidy BeanList, BeanMap, BeanSet
internals
---
ebean-api/src/main/java/io/ebean/common/BeanList.java | 3 +--
ebean-api/src/main/java/io/ebean/common/BeanMap.java | 1 -
ebean-api/src/main/java/io/ebean/common/BeanSet.java | 1 -
3 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/ebean-api/src/main/java/io/ebean/common/BeanList.java b/ebean-api/src/main/java/io/ebean/common/BeanList.java
index 0aa774a81..ba0adca99 100644
--- a/ebean-api/src/main/java/io/ebean/common/BeanList.java
+++ b/ebean-api/src/main/java/io/ebean/common/BeanList.java
@@ -198,10 +198,9 @@ public final class BeanList extends AbstractBeanCollection implements List
}
if (list == null) {
sb.append("deferred ");
-
} else {
sb.append("size[").append(list.size()).append("] ");
- sb.append("list").append(list).append("");
+ sb.append("list").append(list);
}
return sb.toString();
}
diff --git a/ebean-api/src/main/java/io/ebean/common/BeanMap.java b/ebean-api/src/main/java/io/ebean/common/BeanMap.java
index 09b37d38a..2b9ef350d 100644
--- a/ebean-api/src/main/java/io/ebean/common/BeanMap.java
+++ b/ebean-api/src/main/java/io/ebean/common/BeanMap.java
@@ -194,7 +194,6 @@ public final class BeanMap extends AbstractBeanCollection implements Ma
}
if (map == null) {
sb.append("deferred ");
-
} else {
sb.append("size[").append(map.size()).append("]");
sb.append(" map").append(map);
diff --git a/ebean-api/src/main/java/io/ebean/common/BeanSet.java b/ebean-api/src/main/java/io/ebean/common/BeanSet.java
index 880ece106..0c6f0c508 100644
--- a/ebean-api/src/main/java/io/ebean/common/BeanSet.java
+++ b/ebean-api/src/main/java/io/ebean/common/BeanSet.java
@@ -176,7 +176,6 @@ public final class BeanSet extends AbstractBeanCollection implements Set
Date: Fri, 21 May 2021 08:33:31 +1200
Subject: [PATCH 047/111] #2233 Failing test
---
.../org/tests/lazyloadconf/AppConfig.java | 36 +++++++
.../tests/lazyloadconf/AppConfigControl.java | 42 ++++++++
.../java/org/tests/lazyloadconf/MyTest.java | 97 +++++++++++++++++++
.../org/tests/lazyloadconf/Relationship.java | 35 +++++++
4 files changed, 210 insertions(+)
create mode 100644 ebean-core/src/test/java/org/tests/lazyloadconf/AppConfig.java
create mode 100644 ebean-core/src/test/java/org/tests/lazyloadconf/AppConfigControl.java
create mode 100644 ebean-core/src/test/java/org/tests/lazyloadconf/MyTest.java
create mode 100644 ebean-core/src/test/java/org/tests/lazyloadconf/Relationship.java
diff --git a/ebean-core/src/test/java/org/tests/lazyloadconf/AppConfig.java b/ebean-core/src/test/java/org/tests/lazyloadconf/AppConfig.java
new file mode 100644
index 000000000..999ef1aa0
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/lazyloadconf/AppConfig.java
@@ -0,0 +1,36 @@
+package org.tests.lazyloadconf;
+
+import io.ebean.annotation.Cache;
+
+import javax.persistence.*;
+import java.util.List;
+
+@Entity
+@Cache
+@Table(name = "app_config")
+public class AppConfig {
+
+ @Id
+ @Column(name = "id")
+ private Integer id;
+
+ @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "appConfig")
+ //@JoinColumn(name = "id", referencedColumnName = "id")
+ private List items;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public List getItems() {
+ return items;
+ }
+
+ public void setItems(List items) {
+ this.items = items;
+ }
+}
diff --git a/ebean-core/src/test/java/org/tests/lazyloadconf/AppConfigControl.java b/ebean-core/src/test/java/org/tests/lazyloadconf/AppConfigControl.java
new file mode 100644
index 000000000..8da38cd59
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/lazyloadconf/AppConfigControl.java
@@ -0,0 +1,42 @@
+package org.tests.lazyloadconf;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "app_config_control")
+public class AppConfigControl {
+
+ @Id
+ private Integer id;
+
+ private String name;
+
+ @ManyToOne
+ @JoinColumn(name = "config_id", referencedColumnName = "id")
+ private AppConfig appConfig;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public AppConfig getAppConfig() {
+ return appConfig;
+ }
+
+ public void setAppConfig(AppConfig appConfig) {
+ this.appConfig = appConfig;
+ }
+}
+
diff --git a/ebean-core/src/test/java/org/tests/lazyloadconf/MyTest.java b/ebean-core/src/test/java/org/tests/lazyloadconf/MyTest.java
new file mode 100644
index 000000000..34ec36ea7
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/lazyloadconf/MyTest.java
@@ -0,0 +1,97 @@
+package org.tests.lazyloadconf;
+
+import io.ebean.Ebean;
+import io.ebean.Query;
+import org.junit.Test;
+
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class MyTest {
+
+ @Test
+ public void testRe() {
+
+ AppConfig globalAppConfig = new AppConfig();
+ globalAppConfig.setId(1);
+ globalAppConfig.setItems(new ArrayList<>());
+ AppConfigControl global = new AppConfigControl();
+ global.setId(1);
+ global.setName("global");
+ global.setAppConfig(globalAppConfig);
+ globalAppConfig.getItems().add(global);
+ Ebean.save(globalAppConfig);
+
+ AppConfig userAppConfig = new AppConfig();
+ userAppConfig.setId(2);
+ userAppConfig.setItems(new ArrayList<>());
+ AppConfigControl user = new AppConfigControl();
+ user.setId(2);
+ user.setName("user");
+ user.setAppConfig(userAppConfig);
+ userAppConfig.getItems().add(user);
+ Ebean.save(userAppConfig);
+
+ AppConfig otherAppConfig = new AppConfig();
+ otherAppConfig.setId(3);
+ otherAppConfig.setItems(new ArrayList<>());
+ Ebean.save(otherAppConfig);
+
+ Relationship globalRe = new Relationship();
+ globalRe.setId(1);
+ globalRe.setAppConfig(globalAppConfig);
+ Ebean.save(globalRe);
+
+ Relationship userRe = new Relationship();
+ userRe.setId(2);
+ userRe.setAppConfig(userAppConfig);
+ Ebean.save(userRe);
+
+ Relationship otherRe = new Relationship();
+ otherRe.setId(3);
+ otherRe.setAppConfig(otherAppConfig);
+ Ebean.save(otherRe);
+
+
+
+// Start business processing
+ Query relationshipQuery = Ebean.find(Relationship.class);
+ List relationshipList = relationshipQuery.where().idIn(1, 2, 3).findList();
+
+ assertThat(relationshipList.size()).isEqualTo(3);
+
+ Map map = relationshipList.stream()
+ .map(Relationship::getAppConfig)
+ .map((ac) -> new AbstractMap.SimpleImmutableEntry<>(ac.getId(), ac))
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+
+// final List items = DB.find(AppConfig.class)
+// .fetch("items")
+// .findList();
+
+ AppConfig g = map.get(1);
+ AppConfig u = map.get(2);
+ AppConfig o = map.get(3);
+ if(!u.getItems().isEmpty()){
+ g.setItems(u.getItems());
+ }
+
+ assertThat(g.getItems().size()).isEqualTo(1);
+
+// If this line of code is commented out, this test case will be successfully passed
+ assertThat(o.getItems().size()).isEqualTo(0);
+
+// org.junit.ComparisonFailure:
+// Expected :1
+// Actual :2
+ assertThat(g.getItems().size()).isEqualTo(1);
+
+ assertThat(g.getItems().get(0).getName()).isEqualTo("user");
+ }
+
+}
diff --git a/ebean-core/src/test/java/org/tests/lazyloadconf/Relationship.java b/ebean-core/src/test/java/org/tests/lazyloadconf/Relationship.java
new file mode 100644
index 000000000..f59e7677a
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/lazyloadconf/Relationship.java
@@ -0,0 +1,35 @@
+package org.tests.lazyloadconf;
+
+import io.ebean.annotation.Cache;
+
+import javax.persistence.*;
+
+@Entity
+@Cache(enableBeanCache = true)
+@Table(name="app_config_re")
+public class Relationship {
+
+ @Id
+ private Integer id;
+
+ @ManyToOne
+ @JoinColumn(name="config_id",referencedColumnName="id")
+ private AppConfig appConfig;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public AppConfig getAppConfig() {
+ return appConfig;
+ }
+
+ public void setAppConfig(AppConfig appConfig) {
+ this.appConfig = appConfig;
+ }
+}
+
From 77c6f1cb9f97773abd41b13cc4eef950aef608b3 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 21 May 2021 08:44:04 +1200
Subject: [PATCH 048/111] #2233 Tidy failing test Ebean -> DB and rename test
---
...ava => BeanCollectionLazyLoadingTest.java} | 37 ++++++++-----------
1 file changed, 16 insertions(+), 21 deletions(-)
rename ebean-core/src/test/java/org/tests/lazyloadconf/{MyTest.java => BeanCollectionLazyLoadingTest.java} (75%)
diff --git a/ebean-core/src/test/java/org/tests/lazyloadconf/MyTest.java b/ebean-core/src/test/java/org/tests/lazyloadconf/BeanCollectionLazyLoadingTest.java
similarity index 75%
rename from ebean-core/src/test/java/org/tests/lazyloadconf/MyTest.java
rename to ebean-core/src/test/java/org/tests/lazyloadconf/BeanCollectionLazyLoadingTest.java
index 34ec36ea7..b0ef7592b 100644
--- a/ebean-core/src/test/java/org/tests/lazyloadconf/MyTest.java
+++ b/ebean-core/src/test/java/org/tests/lazyloadconf/BeanCollectionLazyLoadingTest.java
@@ -1,6 +1,6 @@
package org.tests.lazyloadconf;
-import io.ebean.Ebean;
+import io.ebean.DB;
import io.ebean.Query;
import org.junit.Test;
@@ -12,10 +12,10 @@ import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
-public class MyTest {
+public class BeanCollectionLazyLoadingTest {
@Test
- public void testRe() {
+ public void test() {
AppConfig globalAppConfig = new AppConfig();
globalAppConfig.setId(1);
@@ -25,7 +25,7 @@ public class MyTest {
global.setName("global");
global.setAppConfig(globalAppConfig);
globalAppConfig.getItems().add(global);
- Ebean.save(globalAppConfig);
+ DB.save(globalAppConfig);
AppConfig userAppConfig = new AppConfig();
userAppConfig.setId(2);
@@ -35,32 +35,31 @@ public class MyTest {
user.setName("user");
user.setAppConfig(userAppConfig);
userAppConfig.getItems().add(user);
- Ebean.save(userAppConfig);
+ DB.save(userAppConfig);
AppConfig otherAppConfig = new AppConfig();
otherAppConfig.setId(3);
otherAppConfig.setItems(new ArrayList<>());
- Ebean.save(otherAppConfig);
+ DB.save(otherAppConfig);
Relationship globalRe = new Relationship();
globalRe.setId(1);
globalRe.setAppConfig(globalAppConfig);
- Ebean.save(globalRe);
+ DB.save(globalRe);
Relationship userRe = new Relationship();
userRe.setId(2);
userRe.setAppConfig(userAppConfig);
- Ebean.save(userRe);
+ DB.save(userRe);
Relationship otherRe = new Relationship();
otherRe.setId(3);
otherRe.setAppConfig(otherAppConfig);
- Ebean.save(otherRe);
+ DB.save(otherRe);
-
-// Start business processing
- Query relationshipQuery = Ebean.find(Relationship.class);
+ // Start business processing
+ Query relationshipQuery = DB.find(Relationship.class);
List relationshipList = relationshipQuery.where().idIn(1, 2, 3).findList();
assertThat(relationshipList.size()).isEqualTo(3);
@@ -70,25 +69,21 @@ public class MyTest {
.map((ac) -> new AbstractMap.SimpleImmutableEntry<>(ac.getId(), ac))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
-// final List items = DB.find(AppConfig.class)
-// .fetch("items")
-// .findList();
-
AppConfig g = map.get(1);
AppConfig u = map.get(2);
AppConfig o = map.get(3);
- if(!u.getItems().isEmpty()){
+ if (!u.getItems().isEmpty()) {
+ // a source of the problem came from invoking lazy loading here
+ // with the setItems call which is unnecessary due to being a ToMany
g.setItems(u.getItems());
}
assertThat(g.getItems().size()).isEqualTo(1);
-// If this line of code is commented out, this test case will be successfully passed
+ // If this line of code is commented out, this test case will be successfully passed
assertThat(o.getItems().size()).isEqualTo(0);
-// org.junit.ComparisonFailure:
-// Expected :1
-// Actual :2
+ // org.junit.ComparisonFailure: Expected :1 Actual :2
assertThat(g.getItems().size()).isEqualTo(1);
assertThat(g.getItems().get(0).getName()).isEqualTo("user");
From 79740accfa688d14988ee6ffe3f21276a8126e33 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 21 May 2021 08:48:42 +1200
Subject: [PATCH 049/111] #2233 Fix with setter on ToMany now not invoking lazy
loading
- ebean-agent changed to not invoke preGetter on ToMany (just like Id)
- EntityBeanIntercept preSetterMany() changed to ensure loading flag set
---
.../src/main/java/io/ebean/bean/EntityBeanIntercept.java | 8 +++++++-
ebean-bom/pom.xml | 4 ++--
ebean-core/pom.xml | 2 +-
ebean-ddl-generator/pom.xml | 2 +-
kotlin-querybean-generator/pom.xml | 2 +-
5 files changed, 12 insertions(+), 6 deletions(-)
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 12f3fda8f..0c2333026 100644
--- a/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java
+++ b/ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java
@@ -85,6 +85,8 @@ public final class EntityBeanIntercept implements Serializable {
*/
private static final byte FLAG_CHANGED_PROP = 2;
+ private static final byte FLAG_CHANGEDLOADED_PROP = 3;
+
/**
* Flags indicating if a property is a dirty embedded bean. Used to distinguish
* between an embedded bean being completely overwritten and one of its
@@ -569,6 +571,10 @@ public final class EntityBeanIntercept implements Serializable {
flags[propertyIndex] |= FLAG_CHANGED_PROP;
}
+ private void setChangeLoaded(int propertyIndex) {
+ flags[propertyIndex] |= FLAG_CHANGEDLOADED_PROP;
+ }
+
/**
* Set that an embedded bean has had one of its properties changed.
*/
@@ -937,7 +943,7 @@ public final class EntityBeanIntercept implements Serializable {
if (readOnly) {
throw new IllegalStateException("This bean is readOnly");
}
- setChangedProperty(propertyIndex);
+ setChangeLoaded(propertyIndex);
}
}
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index aaa2b5961..edc2708cf 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -18,8 +18,8 @@
12.4.0
4.1
7.0
- 12.8.2
- 12.8.2
+ 12.8.4
+ 12.8.4
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 13732d513..559d763ac 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -302,7 +302,7 @@
io.ebean
ebean-maven-plugin
- 12.8.2
+ 12.8.4
test
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index f94924830..0c5089130 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -76,7 +76,7 @@
io.ebean
ebean-maven-plugin
- 12.8.2
+ 12.8.4
test
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index a556671bb..99433a038 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -146,7 +146,7 @@
io.ebean
ebean-maven-plugin
- 12.8.2
+ 12.8.4
test
From 676bac390ea018b895903bfaee026e57808cf9ee Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 21 May 2021 09:01:45 +1200
Subject: [PATCH 050/111] #2233 Followup change that unsets load buffer from
BeanCollection
- Clears the buffer after it has been used to load BeanCollection's
- Sets the BeanCollection to use the server rather than the Load Buffer just in case there are subsequent calls for loading (which there should not be)
---
.../io/ebeaninternal/api/LoadManyRequest.java | 15 +++------------
.../server/loadcontext/DLoadManyContext.java | 9 ++++-----
2 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java b/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java
index d7dc2f56a..aeb9ff7dd 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java
@@ -71,7 +71,6 @@ public class LoadManyRequest extends LoadRequest {
* This for use when lazy loading is invoked on methods such as clear() and removeAll() where it
* generally makes sense to only fetch the Id values as the other property information is not
* used.
- *
*/
private boolean isOnlyIds() {
return onlyIds;
@@ -91,18 +90,16 @@ public class LoadManyRequest extends LoadRequest {
return loadContext.getBatchSize();
}
- private List getParentIdList() {
-
+ private List parentIdList(SpiEbeanServer server) {
List idList = new ArrayList<>();
-
BeanPropertyAssocMany> many = getMany();
for (BeanCollection> bc : batch) {
idList.add(many.getParentId(bc.getOwnerBean()));
+ bc.setLoader(server); // don't use the load buffer again
}
if (many.getTargetDescriptor().isPadInExpression()) {
BindPadding.padIds(idList);
}
-
return idList;
}
@@ -111,9 +108,7 @@ public class LoadManyRequest extends LoadRequest {
}
public SpiQuery> createQuery(SpiEbeanServer server) {
-
BeanPropertyAssocMany> many = getMany();
-
SpiQuery> query = many.newQuery(server);
String orderBy = many.getLazyFetchOrderBy();
if (orderBy != null) {
@@ -128,7 +123,7 @@ public class LoadManyRequest extends LoadRequest {
}
query.setLazyLoadForParents(many);
- many.addWhereParentIdIn(query, getParentIdList(), loadContext.isUseDocStore());
+ many.addWhereParentIdIn(query, parentIdList(server), loadContext.isUseDocStore());
query.setPersistenceContext(loadContext.getPersistenceContext());
String mode = isLazy() ? "+lazy" : "+query";
@@ -146,7 +141,6 @@ public class LoadManyRequest extends LoadRequest {
// override to just select the Id values
query.select(many.getTargetIdProperty());
}
-
return query;
}
@@ -154,10 +148,8 @@ public class LoadManyRequest extends LoadRequest {
* After the query execution check for empty collections and load L2 cache if desired.
*/
public void postLoad() {
-
BeanDescriptor> desc = loadContext.getBeanDescriptor();
BeanPropertyAssocMany> many = getMany();
-
// check for BeanCollection's that where never processed
// in the +query or +lazy load due to no rows (predicates)
for (BeanCollection> bc : batch) {
@@ -172,6 +164,5 @@ public class LoadManyRequest extends LoadRequest {
desc.cacheManyPropPut(many, bc, parentId);
}
}
-
}
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java
index 5035f0802..5d2b781c7 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/loadcontext/DLoadManyContext.java
@@ -201,7 +201,6 @@ class DLoadManyContext extends DLoadBaseContext implements LoadManyContext {
@Override
public void loadMany(BeanCollection> bc, boolean onlyIds) {
-
lock.lock();
try {
boolean useCache = !onlyIds && context.hitCache && context.property.isUseCache();
@@ -215,6 +214,7 @@ class DLoadManyContext extends DLoadBaseContext implements LoadManyContext {
// find it using instance equality - avoiding equals() and potential deadlock issue
if (list.get(i) == bc) {
list.remove(i);
+ bc.setLoader(context.parent.getEbeanServer());
return;
}
}
@@ -222,10 +222,9 @@ class DLoadManyContext extends DLoadBaseContext implements LoadManyContext {
}
}
- // Should reduce the list by checking each beanCollection in the L2 first before executing the query
-
- LoadManyRequest req = new LoadManyRequest(this, onlyIds, useCache);
- context.parent.getEbeanServer().loadMany(req);
+ context.parent.getEbeanServer().loadMany(new LoadManyRequest(this, onlyIds, useCache));
+ // clear the buffer as all entries have been loaded
+ list.clear();
} finally {
lock.unlock();
}
From 643b0499c44c9ec9b2215fdb83349d262ead8208 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 21 May 2021 16:09:15 +1200
Subject: [PATCH 051/111] #2233 Add ebean-version.mf so ebean-agent can sniff
the internal version
This allows the ebean-agent to support the older behaviour. Devs using the latest IntelliJ ebean plugin will get the old behaviour unless they bump ebean-core to 12.9 or later.
---
ebean-core/src/main/resources/META-INF/ebean-version.mf | 1 +
1 file changed, 1 insertion(+)
create mode 100644 ebean-core/src/main/resources/META-INF/ebean-version.mf
diff --git a/ebean-core/src/main/resources/META-INF/ebean-version.mf b/ebean-core/src/main/resources/META-INF/ebean-version.mf
new file mode 100644
index 000000000..6bcacf1d6
--- /dev/null
+++ b/ebean-core/src/main/resources/META-INF/ebean-version.mf
@@ -0,0 +1 @@
+ebean-version: 129
From 0da86a82ae74dd2f90c045fb1c842cf1d18ecae4 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 21 May 2021 17:14:49 +1200
Subject: [PATCH 052/111] #2233 Bump to ebean-agent 12.9.0
---
ebean-bom/pom.xml | 4 ++--
ebean-core/pom.xml | 2 +-
ebean-ddl-generator/pom.xml | 2 +-
kotlin-querybean-generator/pom.xml | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index edc2708cf..6109effa9 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -18,8 +18,8 @@
12.4.0
4.1
7.0
- 12.8.4
- 12.8.4
+ 12.9.0
+ 12.9.0
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 559d763ac..624e91c91 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -302,7 +302,7 @@
io.ebean
ebean-maven-plugin
- 12.8.4
+ 12.9.0
test
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 0c5089130..d063c222c 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -76,7 +76,7 @@
io.ebean
ebean-maven-plugin
- 12.8.4
+ 12.9.0
test
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 99433a038..e7967307e 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -146,7 +146,7 @@
io.ebean
ebean-maven-plugin
- 12.8.4
+ 12.9.0
test
From 2a6108087ca01e5ba8ae192c2912cfe1c43ead83 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 21 May 2021 17:18:30 +1200
Subject: [PATCH 053/111] Bump version to 12.9.0-SNAPSHOT
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 4 ++--
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 8 ++++----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 8 ++++----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 2 +-
querybean-generator/pom.xml | 2 +-
16 files changed, 59 insertions(+), 59 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 380438cc2..10e919049 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index 590680c8a..1c7d48b4e 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 6109effa9..dc1478d34 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-api
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-core-type
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-ddl-generator
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-externalmapping-xml
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-autotune
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-querybean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
querybean-generator
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
io.ebean
kotlin-querybean-generator
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
io.ebean
ebean-test
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
io.ebean
ebean-postgis
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-redis
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index 04497471c..e6589d839 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 624e91c91..16e400f91 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean-core
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-core-type
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index d063c222c..6b16e9b2a 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index 079eebec9..57372b097 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index bcf9f10ff..0fb961ac4 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
io.ebean
ebean-ddl-generator
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index 4e1b6063b..e000db688 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index ff6dd8754..57b01e349 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
io.ebean
querybean-generator
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
io.ebean
ebean-test
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index 573fbcf3b..c500e7508 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
io.ebean
ebean-querybean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
io.ebean
querybean-generator
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
io.ebean
ebean-test
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index c3ed1f57f..94cba52d6 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
provided
io.ebean
ebean-ddl-generator
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
diff --git a/ebean/pom.xml b/ebean/pom.xml
index ba312953f..d284c0bda 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
io.ebean
ebean-querybean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index e7967307e..a475fdcc4 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
test
diff --git a/pom.xml b/pom.xml
index fb82113fa..14f2e3f08 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
pom
ebean parent
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index 1ea632096..d5d769ac4 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.8.4-SNAPSHOT
+ 12.9.0-SNAPSHOT
querybean generator
From 3c4d600187c2443016e56635d0b8afb7a6a1db39 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Sun, 23 May 2021 17:17:34 +1200
Subject: [PATCH 054/111] #2223 #2224 Support BeanMap modification via
entrySet() and keySet()
---
.../main/java/io/ebean/common/BeanMap.java | 20 +-
.../io/ebean/common/ModifyCollection.java | 2 +-
.../java/io/ebean/common/ModifyEntrySet.java | 131 +++++++++
.../java/io/ebean/common/ModifyKeySet.java | 126 +++++++++
.../main/java/io/ebean/common/ModifySet.java | 24 --
.../java/io/ebean/common/BeanMapTest.java | 265 +++++++++++++++++-
.../model/map/BeanMapOrphanRemovalTest.java | 50 ++++
.../test/java/org/tests/model/map/MpUser.java | 12 +-
8 files changed, 572 insertions(+), 58 deletions(-)
create mode 100644 ebean-api/src/main/java/io/ebean/common/ModifyEntrySet.java
create mode 100644 ebean-api/src/main/java/io/ebean/common/ModifyKeySet.java
delete mode 100644 ebean-api/src/main/java/io/ebean/common/ModifySet.java
create mode 100644 ebean-core/src/test/java/org/tests/model/map/BeanMapOrphanRemovalTest.java
diff --git a/ebean-api/src/main/java/io/ebean/common/BeanMap.java b/ebean-api/src/main/java/io/ebean/common/BeanMap.java
index 2b9ef350d..643febc14 100644
--- a/ebean-api/src/main/java/io/ebean/common/BeanMap.java
+++ b/ebean-api/src/main/java/io/ebean/common/BeanMap.java
@@ -175,10 +175,6 @@ public final class BeanMap extends AbstractBeanCollection implements Ma
/**
* Returns the map entrySet.
- *
- * This is because the key values may need to be set against the details (so
- * they don't need to be set twice).
- *
*/
@Override
public Collection> getActualEntries() {
@@ -242,17 +238,12 @@ public final class BeanMap extends AbstractBeanCollection implements Ma
}
@Override
- @SuppressWarnings({"unchecked"})
public Set> entrySet() {
init();
if (isReadOnly()) {
return Collections.unmodifiableSet(map.entrySet());
}
- if (modifyListening) {
- Set> s = map.entrySet();
- return new ModifySet(this, s);
- }
- return map.entrySet();
+ return modifyListening ? new ModifyEntrySet<>(this, map.entrySet()) : map.entrySet();
}
@Override
@@ -273,8 +264,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma
if (isReadOnly()) {
return Collections.unmodifiableSet(map.keySet());
}
- // we don't really care about modifications to the ketSet?
- return map.keySet();
+ return modifyListening ? new ModifyKeySet<>(this, map.keySet()) : map.keySet();
}
@Override
@@ -345,11 +335,7 @@ public final class BeanMap extends AbstractBeanCollection implements Ma
if (isReadOnly()) {
return Collections.unmodifiableCollection(map.values());
}
- if (modifyListening) {
- Collection c = map.values();
- return new ModifyCollection<>(this, c);
- }
- return map.values();
+ return modifyListening ? new ModifyCollection<>(this, map.values()) : map.values();
}
@Override
diff --git a/ebean-api/src/main/java/io/ebean/common/ModifyCollection.java b/ebean-api/src/main/java/io/ebean/common/ModifyCollection.java
index 05b203a2f..48f703ba8 100644
--- a/ebean-api/src/main/java/io/ebean/common/ModifyCollection.java
+++ b/ebean-api/src/main/java/io/ebean/common/ModifyCollection.java
@@ -25,7 +25,7 @@ class ModifyCollection implements Collection {
* The owner is notified of the additions and removals.
*
*/
- public ModifyCollection(BeanCollection owner, Collection c) {
+ ModifyCollection(BeanCollection owner, Collection c) {
this.owner = owner;
this.c = c;
}
diff --git a/ebean-api/src/main/java/io/ebean/common/ModifyEntrySet.java b/ebean-api/src/main/java/io/ebean/common/ModifyEntrySet.java
new file mode 100644
index 000000000..174863a74
--- /dev/null
+++ b/ebean-api/src/main/java/io/ebean/common/ModifyEntrySet.java
@@ -0,0 +1,131 @@
+package io.ebean.common;
+
+import java.util.*;
+
+/**
+ * Handles the Entry Set for BeanMap.
+ */
+class ModifyEntrySet implements Set> {
+
+ private final BeanMap owner;
+ private final Set> entrySet;
+
+ ModifyEntrySet(BeanMap owner, Set> entrySet) {
+ this.owner = owner;
+ this.entrySet = entrySet;
+ }
+
+ @Override
+ public int size() {
+ return entrySet.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return entrySet.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return entrySet.contains(o);
+ }
+
+ @Override
+ public Object[] toArray() {
+ return entrySet.toArray();
+ }
+
+ @Override
+ public T[] toArray(T[] a) {
+ return entrySet.toArray(a);
+ }
+
+ @Override
+ public boolean containsAll(Collection> entries) {
+ return entrySet.containsAll(entries);
+ }
+
+ @Override
+ public void clear() {
+ owner.clear();
+ }
+
+ @Override
+ public boolean add(Map.Entry entry) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection extends Map.Entry> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public boolean remove(Object o) {
+ if (o instanceof Map.Entry) {
+ Map.Entry entry = (Map.Entry) o;
+ final E val = owner.get(entry.getKey());
+ if (Objects.equals(val, entry.getValue())) {
+ owner.remove(entry.getKey());
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean retainAll(Collection> entries) {
+ boolean modified = false;
+ final Iterator> it = iterator();
+ while (it.hasNext()) {
+ if (!entries.contains(it.next())) {
+ it.remove();
+ modified = true;
+ }
+ }
+ return modified;
+ }
+
+ @Override
+ public boolean removeAll(Collection> entries) {
+ boolean modified = false;
+ for (Object entry : entries) {
+ modified |= remove(entry);
+ }
+ return modified;
+ }
+
+ @Override
+ public Iterator> iterator() {
+ return new EntrySetIterator(new ArrayList<>(entrySet).iterator());
+ }
+
+ class EntrySetIterator implements Iterator> {
+
+ private final Iterator> iterator;
+ private Map.Entry entry;
+
+ EntrySetIterator(Iterator> iterator) {
+ this.iterator = iterator;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public Map.Entry next() {
+ entry = iterator.next();
+ return entry;
+ }
+
+ @Override
+ public void remove() {
+ owner.remove(entry.getKey());
+ iterator.remove();
+ }
+ }
+
+}
diff --git a/ebean-api/src/main/java/io/ebean/common/ModifyKeySet.java b/ebean-api/src/main/java/io/ebean/common/ModifyKeySet.java
new file mode 100644
index 000000000..e9f829b9b
--- /dev/null
+++ b/ebean-api/src/main/java/io/ebean/common/ModifyKeySet.java
@@ -0,0 +1,126 @@
+package io.ebean.common;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Handle the Key Set for BeanMap.
+ */
+class ModifyKeySet implements Set {
+
+ private final Set keySet;
+ private final BeanMap owner;
+
+ ModifyKeySet(BeanMap owner, Set keySet) {
+ this.owner = owner;
+ this.keySet = keySet;
+ }
+
+ @Override
+ public int size() {
+ return keySet.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return keySet.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return keySet.contains(o);
+ }
+
+ @Override
+ public Object[] toArray() {
+ return keySet.toArray();
+ }
+
+ @Override
+ public T[] toArray(T[] a) {
+ return keySet.toArray(a);
+ }
+
+ @Override
+ public boolean add(E key) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection extends E> keys) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ return owner.remove(o) != null;
+ }
+
+ @Override
+ public boolean containsAll(Collection> keys) {
+ return keySet.containsAll(keys);
+ }
+
+ @Override
+ public void clear() {
+ owner.clear();
+ }
+
+ @Override
+ public Iterator iterator() {
+ return new KeySetIterator<>(new ArrayList<>(keySet).iterator());
+ }
+
+ @Override
+ public boolean retainAll(Collection> keys) {
+ return keysMatch(keys, false);
+ }
+
+ @Override
+ public boolean removeAll(Collection> keys) {
+ return keysMatch(keys, true);
+ }
+
+ private boolean keysMatch(Collection> keys, boolean containsMatch) {
+ boolean changed = false;
+ final Iterator iterator = iterator();
+ while (iterator.hasNext()) {
+ final E key = iterator.next();
+ if (keys.contains(key) == containsMatch) {
+ iterator.remove();
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+
+ class KeySetIterator implements Iterator {
+
+ private final Iterator iterator;
+ private K key;
+
+ KeySetIterator(Iterator iterator) {
+ this.iterator = iterator;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public K next() {
+ key = iterator.next();
+ return key;
+ }
+
+ @Override
+ public void remove() {
+ owner.remove(key);
+ iterator.remove();
+ }
+ }
+}
diff --git a/ebean-api/src/main/java/io/ebean/common/ModifySet.java b/ebean-api/src/main/java/io/ebean/common/ModifySet.java
deleted file mode 100644
index 1a0a2e1bf..000000000
--- a/ebean-api/src/main/java/io/ebean/common/ModifySet.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package io.ebean.common;
-
-import io.ebean.bean.BeanCollection;
-
-import java.util.Set;
-
-/**
- * Wraps a Set for the purposes of notifying removals and additions to the
- * BeanCollection owner.
- *
- * This is required for persisting ManyToMany objects. Additions and removals
- * become inserts and deletes to the intersection table.
- *
- */
-class ModifySet extends ModifyCollection implements Set {
-
- /**
- * Create with an Owner that is notified of any additions or deletions.
- */
- public ModifySet(BeanCollection owner, Set s) {
- super(owner, s);
- }
-
-}
diff --git a/ebean-core/src/test/java/io/ebean/common/BeanMapTest.java b/ebean-core/src/test/java/io/ebean/common/BeanMapTest.java
index 08a57e05a..003539a72 100644
--- a/ebean-core/src/test/java/io/ebean/common/BeanMapTest.java
+++ b/ebean-core/src/test/java/io/ebean/common/BeanMapTest.java
@@ -2,18 +2,21 @@ package io.ebean.common;
import io.ebean.bean.BeanCollection;
import org.junit.Test;
+import org.tests.model.basic.EBasic;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.*;
+import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
public class BeanMapTest {
- Object object1 = new Object();
- Object object2 = new Object();
- Object object3 = new Object();
+ private final EBasic object1 = new EBasic("o1");
+ private final EBasic object2 = new EBasic("o2");
+ private final EBasic object3 = new EBasic("o3");
+ private final EBasic object4 = new EBasic("o4");
+ private final EBasic object5 = new EBasic("o5");
private Map all() {
Map all = new LinkedHashMap<>();
@@ -174,9 +177,7 @@ public class BeanMapTest {
@Test
public void testClear_given_someBeansInAdditions() throws Exception {
- BeanMap map = new BeanMap<>();
- map.put("1", object1);
- map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
+ BeanMap map = newModifyListeningMap();
map.put("2", object2);
map.put("3", object3);
@@ -188,4 +189,252 @@ public class BeanMapTest {
assertThat(map.getModifyAdditions()).isEmpty();
}
+ @Test(expected = UnsupportedOperationException.class)
+ public void keySet_add_whenModifyListening() {
+ BeanMap map = newModifyListeningMap();
+ map.keySet().add("3");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void keySet_add() {
+ BeanMap map = new BeanMap<>();
+ map.keySet().add("3");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void keySet_addAll_whenModifyListening() {
+ BeanMap map = newModifyListeningMap();
+ map.keySet().addAll(asList("3", "4"));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void keySet_addAll() {
+ BeanMap map = new BeanMap<>();
+ map.keySet().addAll(asList("3", "4"));
+ }
+
+ @Test
+ public void keySet_remove() {
+
+ BeanMap map = new BeanMap<>();
+ map.put("1", object1);
+ map.put("2", object2);
+ map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
+
+ final Set keySet = map.keySet();
+ keySet.remove("1");
+
+ assertThat(keySet.contains("1")).isFalse();
+ assertThat(map).doesNotContainKeys("1");
+ assertThat(map.get("1")).isNull();
+
+ assertThat(map.getModifyRemovals()).containsExactly(object1);
+ }
+
+ @Test
+ public void keySet_clear() {
+
+ BeanMap map = new BeanMap<>();
+ map.put("1", object1);
+ map.put("2", object2);
+ map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
+
+ final Set keySet = map.keySet();
+ keySet.clear();
+
+ assertThat(map).isEmpty();
+ assertThat(keySet).isEmpty();
+
+ assertThat(map.getModifyRemovals()).containsExactly(object1, object2);
+ }
+
+ @Test
+ public void keySet_iterator_remove() {
+
+ BeanMap map = new BeanMap<>();
+ map.put("1", object1);
+ map.put("2", object2);
+ map.put("3", object3);
+ map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
+
+ final Set keySet = map.keySet();
+ final Iterator iterator = keySet.iterator();
+ while (iterator.hasNext()) {
+ final String key = iterator.next();
+ if (key.equals("2")) {
+ iterator.remove();
+ }
+ }
+
+ assertThat(map).hasSize(2);
+ assertThat(keySet).hasSize(2);
+ assertThat(keySet).containsExactly("1", "3");
+ assertThat(map).containsKeys("1", "3");
+
+ assertThat(map.getModifyRemovals()).containsExactly(object2);
+ }
+
+ @Test
+ public void keySet_removeAll() {
+
+ BeanMap map = new BeanMap<>();
+ map.put("1", object1);
+ map.put("2", object2);
+ map.put("3", object3);
+ map.put("4", object4);
+ map.put("5", object5);
+ map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
+
+ final Set keySet = map.keySet();
+ final boolean changed = keySet.removeAll(asList("2", "3", "5"));
+
+ assertThat(changed).isTrue();
+ assertThat(map).hasSize(2);
+ assertThat(keySet).hasSize(2);
+ assertThat(keySet).containsExactly("1", "4");
+ assertThat(map).containsKeys("1", "4");
+
+ assertThat(map.getModifyRemovals()).containsExactly(object2, object3, object5);
+ }
+
+
+ @Test
+ public void keySet_retainAll() {
+
+ BeanMap map = new BeanMap<>();
+ map.put("1", object1);
+ map.put("2", object2);
+ map.put("3", object3);
+ map.put("4", object4);
+ map.put("5", object5);
+ map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
+
+ final Set keySet = map.keySet();
+ final boolean changed = keySet.retainAll(asList("2", "3", "5"));
+
+ assertThat(changed).isTrue();
+ assertThat(map).hasSize(3);
+ assertThat(keySet).hasSize(3);
+ assertThat(keySet).containsExactly("2", "3", "5");
+ assertThat(map).containsKeys("2", "3", "5");
+
+ assertThat(map.getModifyRemovals()).containsExactly(object1, object4);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void values_add() {
+ BeanMap map = new BeanMap<>();
+ map.values().add(object3);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void values_addAll() {
+ BeanMap map = new BeanMap<>();
+ map.values().addAll(asList(object3, object5));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void entrySet_add() {
+ newModifyListeningMap()
+ .entrySet()
+ .add(new AbstractMap.SimpleEntry<>("3", object3));
+ }
+
+ @Test
+ public void entrySet_clear() {
+ final BeanMap map = newModifyListeningMap();
+ final Set> entries = map.entrySet();
+ entries.clear();
+
+ assertThat(entries).isEmpty();
+ assertThat(map).isEmpty();
+ assertThat(map.getModifyRemovals()).containsExactly(object1);
+ }
+
+ @Test
+ public void entrySet_remove() {
+ final BeanMap map = newModifyListeningMap5();
+ final Set> entries = map.entrySet();
+
+ assertThat(map).hasSize(5);
+
+ final boolean existed1 = entries.remove(new AbstractMap.SimpleEntry<>("1", object1));
+ assertThat(existed1).isTrue();
+
+ final boolean existed22 = entries.remove(new AbstractMap.SimpleEntry<>("22", object1));
+ assertThat(existed22).isFalse();
+
+ assertThat(map).hasSize(4);
+ assertThat(map.getModifyRemovals()).containsExactly(object1);
+ }
+
+ @Test
+ public void entrySet_remove_whenNotEqualValue() {
+ final BeanMap map = newModifyListeningMap5();
+ final Set> entries = map.entrySet();
+
+ assertThat(map).hasSize(5);
+
+ final boolean modified = entries.remove(new AbstractMap.SimpleEntry<>("1", object2));
+ assertThat(modified).isFalse();
+
+ assertThat(map).hasSize(5);
+ assertThat(map.getModifyRemovals()).isNull();
+ }
+
+ @Test
+ public void entrySet_iterator_remove() {
+ final BeanMap map = newModifyListeningMap5();
+ final Set> entries = map.entrySet();
+ final Iterator> iterator = entries.iterator();
+ while (iterator.hasNext()) {
+ final Map.Entry entry = iterator.next();
+ if (entry.getKey().equals("2") || entry.getKey().equals("5")) {
+ iterator.remove();
+ }
+ }
+ assertThat(map).hasSize(3);
+ assertThat(entries).hasSize(3);
+ assertThat(map.getModifyRemovals()).containsExactly(object2, object5);
+ }
+
+ @Test
+ public void entrySet_removeAll() {
+ final BeanMap map = newModifyListeningMap5();
+ final Set> entries = map.entrySet();
+
+ entries.removeAll(asList(new AbstractMap.SimpleEntry<>("1", object1), new AbstractMap.SimpleEntry<>("3", object4), new AbstractMap.SimpleEntry<>("4", object4)));
+ assertThat(map).hasSize(3);
+ assertThat(entries).hasSize(3);
+ assertThat(map.getModifyRemovals()).containsExactly(object1, object4);
+ }
+
+ @Test
+ public void entrySet_retainAll() {
+ final BeanMap map = newModifyListeningMap5();
+ final Set> entries = map.entrySet();
+
+ entries.retainAll(asList(new AbstractMap.SimpleEntry<>("1", object1), new AbstractMap.SimpleEntry<>("3", object4), new AbstractMap.SimpleEntry<>("4", object4)));
+ assertThat(map).hasSize(2);
+ assertThat(entries).hasSize(2);
+ assertThat(map.getModifyRemovals()).containsExactly(object2, object3, object5);
+ }
+
+ private BeanMap newModifyListeningMap() {
+ BeanMap map = new BeanMap<>();
+ map.put("1", object1);
+ map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
+ return map;
+ }
+
+ private BeanMap newModifyListeningMap5() {
+ BeanMap map = new BeanMap<>();
+ map.put("1", object1);
+ map.put("2", object2);
+ map.put("3", object3);
+ map.put("4", object4);
+ map.put("5", object5);
+ map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
+ return map;
+ }
}
diff --git a/ebean-core/src/test/java/org/tests/model/map/BeanMapOrphanRemovalTest.java b/ebean-core/src/test/java/org/tests/model/map/BeanMapOrphanRemovalTest.java
new file mode 100644
index 000000000..48288e7a3
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/model/map/BeanMapOrphanRemovalTest.java
@@ -0,0 +1,50 @@
+package org.tests.model.map;
+
+import io.ebean.DB;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+
+public class BeanMapOrphanRemovalTest {
+
+ @Test
+ public void keySet_retainAll() {
+
+ MpUser user = new MpUser();
+ user.setName("u1");
+ addRoles(user, "r1", "r2", "r3", "r4");
+ DB.save(user);
+
+ final MpUser user1 = DB.find(MpUser.class, user.getId());
+ final Map roles = user1.getRoles();
+ assertThat(roles).hasSize(4);
+
+
+ final Set keySet = roles.keySet();
+ keySet.retainAll(Arrays.asList("r2", "r3"));
+
+ DB.save(user1);
+
+ final MpUser user2 = DB.find(MpUser.class, user.getId());
+ final Map roles2 = user2.getRoles();
+ assertThat(roles2).hasSize(2);
+ }
+
+ private void addRoles(MpUser user, String... roles){
+ for (String code : roles) {
+ MpRole role = newRole(code);
+ user.getRoles().put(role.getCode(), role);
+ }
+ }
+
+ private MpRole newRole(String code) {
+ MpRole role = new MpRole();
+ role.setCode(code);
+ return role;
+ }
+}
diff --git a/ebean-core/src/test/java/org/tests/model/map/MpUser.java b/ebean-core/src/test/java/org/tests/model/map/MpUser.java
index 100e1e6a7..94edddb19 100644
--- a/ebean-core/src/test/java/org/tests/model/map/MpUser.java
+++ b/ebean-core/src/test/java/org/tests/model/map/MpUser.java
@@ -1,11 +1,7 @@
package org.tests.model.map;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.MapKey;
-import javax.persistence.OneToMany;
-import java.util.HashMap;
+import javax.persistence.*;
+import java.util.LinkedHashMap;
import java.util.Map;
@Entity
@@ -16,9 +12,9 @@ public class MpUser {
private String name;
- @OneToMany(cascade = CascadeType.ALL)
+ @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@MapKey(name = "code")
- public Map roles = new HashMap<>();
+ private Map roles = new LinkedHashMap<>();
public Long getId() {
return id;
From 2158925d3ca77b9610c3ae03c244594d74ed6639 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Sun, 23 May 2021 21:28:11 +1200
Subject: [PATCH 055/111] #2202 - kotlin-maven-plugin issue with JDK 16
InaccessibleObjectException: Unable to make protected void java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens java.util" to unnamed module @62732be7
---
kotlin-querybean-generator/pom.xml | 75 +++++++++++++++---------------
1 file changed, 37 insertions(+), 38 deletions(-)
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index a475fdcc4..917d4275a 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -12,7 +12,7 @@
kotlin-querybean-generator
- 1.4.31
+ 1.5.0
@@ -81,43 +81,42 @@
src/test/kotlin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+ ${kotlin.version}
+
+
+ test-compile
+ test-compile
+
+ test-compile
+
+
+
+ test-kapt
+
+ test-kapt
+
+
+
+ src/test/kotlin
+
+
+
+ io.ebean
+ kotlin-querybean-generator
+ 12.8.2
+
+
+
+
+
+
+ 1.8
+
+
+
org.apache.maven.plugins
maven-compiler-plugin
From 01bce5cfa622af053545ce15f885d1a25a2e0337 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Sun, 23 May 2021 22:20:40 +1200
Subject: [PATCH 056/111] #2226 - Automatically determining join columns and
ignoring PrimaryKeyJoinColumn.name Id warning when I want to use Id as a
foreign key
Improve the message and dropping to INFO level.
---
.../server/deploy/parse/AnnotationAssocOnes.java | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java
index d313ce925..b5929d6a0 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java
@@ -54,7 +54,6 @@ public class AnnotationAssocOnes extends AnnotationAssoc {
}
private void readAssocOne(DeployBeanPropertyAssocOne> prop) {
-
ManyToOne manyToOne = get(prop, ManyToOne.class);
if (manyToOne != null) {
readManyToOne(manyToOne, prop);
@@ -183,7 +182,6 @@ public class AnnotationAssocOnes extends AnnotationAssoc {
}
private void readManyToOne(ManyToOne propAnn, DeployBeanPropertyAssocOne> beanProp) {
-
setCascadeTypes(propAnn.cascade(), beanProp.getCascadeInfo());
setTargetType(propAnn.targetEntity(), beanProp);
setBeanTable(beanProp);
@@ -194,7 +192,6 @@ public class AnnotationAssocOnes extends AnnotationAssoc {
}
private void readOneToOne(OneToOne propAnn, DeployBeanPropertyAssocOne> prop) {
-
prop.setOneToOne();
prop.setDbInsertable(true);
prop.setDbUpdateable(true);
@@ -223,21 +220,19 @@ public class AnnotationAssocOnes extends AnnotationAssoc {
}
private void readPrimaryKeyJoin(PrimaryKeyJoinColumn primaryKeyJoin, DeployBeanPropertyAssocOne> prop) {
-
if (!prop.isOneToOne()) {
throw new IllegalStateException("Expecting property " + prop.getFullBeanName() + " with PrimaryKeyJoinColumn to be a OneToOne?");
}
prop.setPrimaryKeyJoin(true);
if (!primaryKeyJoin.name().isEmpty()) {
- log.warn("Automatically determining join columns and ignoring PrimaryKeyJoinColumn.name {} on {}", primaryKeyJoin.name(), prop.getFullBeanName());
+ log.info("Automatically determining join columns for @PrimaryKeyJoinColumn - ignoring PrimaryKeyJoinColumn.name attribute [{}] on {}", primaryKeyJoin.name(), prop.getFullBeanName());
}
if (!primaryKeyJoin.referencedColumnName().isEmpty()) {
- log.warn("Automatically determining join columns and Ignoring PrimaryKeyJoinColumn.referencedColumnName {} on {}", primaryKeyJoin.referencedColumnName(), prop.getFullBeanName());
+ log.info("Automatically determining join columns for @PrimaryKeyJoinColumn - Ignoring PrimaryKeyJoinColumn.referencedColumnName attribute [{}] on {}", primaryKeyJoin.referencedColumnName(), prop.getFullBeanName());
}
BeanTable baseBeanTable = factory.getBeanTable(info.getDescriptor().getBeanType());
-
String localPrimaryKey = baseBeanTable.getIdColumn();
String foreignColumn = getBeanTable(prop).getIdColumn();
@@ -245,7 +240,6 @@ public class AnnotationAssocOnes extends AnnotationAssoc {
}
private void readEmbedded(DeployBeanPropertyAssocOne> prop, Embedded embedded) {
-
if (descriptor.isDocStoreOnly() && prop.getDocStoreDoc() == null) {
prop.setDocStoreEmbedded("");
}
@@ -257,7 +251,6 @@ public class AnnotationAssocOnes extends AnnotationAssoc {
} catch (NoSuchMethodError e) {
// using standard JPA API without prefix option, maybe in EE container
}
-
readEmbeddedAttributeOverrides(prop);
}
From 4c317f11ae097acd5414bf7414b2e592b1ee3d68 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Sun, 23 May 2021 22:21:05 +1200
Subject: [PATCH 057/111] Add additional test for PrimaryKeyJoinColumn
---
.../tests/model/onetoone/calcd/CalcDData.java | 46 +++++++++++++++++++
.../model/onetoone/calcd/CalcDInput.java | 42 +++++++++++++++++
.../TestOneToOnePrimaryKeyJoinMapping.java | 26 +++++++++++
3 files changed, 114 insertions(+)
create mode 100644 ebean-core/src/test/java/org/tests/model/onetoone/calcd/CalcDData.java
create mode 100644 ebean-core/src/test/java/org/tests/model/onetoone/calcd/CalcDInput.java
create mode 100644 ebean-core/src/test/java/org/tests/model/onetoone/calcd/TestOneToOnePrimaryKeyJoinMapping.java
diff --git a/ebean-core/src/test/java/org/tests/model/onetoone/calcd/CalcDData.java b/ebean-core/src/test/java/org/tests/model/onetoone/calcd/CalcDData.java
new file mode 100644
index 000000000..eef657be5
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/model/onetoone/calcd/CalcDData.java
@@ -0,0 +1,46 @@
+package org.tests.model.onetoone.calcd;
+
+import io.ebean.Model;
+import io.ebean.annotation.ConstraintMode;
+import io.ebean.annotation.DbForeignKey;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "calcd_data")
+public class CalcDData extends Model {
+
+ @Id
+ private Integer id;
+
+ @OneToOne(optional = false, cascade = CascadeType.ALL)
+ @DbForeignKey(onDelete = ConstraintMode.CASCADE)
+ @PrimaryKeyJoinColumn//(name = "Id", referencedColumnName = "Id")
+ private CalcDInput input;
+
+ private final String name;
+
+ public CalcDData(String name) {
+ this.name = name;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public CalcDInput getInput() {
+ return input;
+ }
+
+ public void setInput(CalcDInput input) {
+ this.input = input;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/ebean-core/src/test/java/org/tests/model/onetoone/calcd/CalcDInput.java b/ebean-core/src/test/java/org/tests/model/onetoone/calcd/CalcDInput.java
new file mode 100644
index 000000000..00704eb27
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/model/onetoone/calcd/CalcDInput.java
@@ -0,0 +1,42 @@
+package org.tests.model.onetoone.calcd;
+
+import io.ebean.Model;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "calcd_input")
+public class CalcDInput extends Model {
+
+ @Id
+ private Integer id;
+
+ @OneToOne(optional = false, fetch = FetchType.EAGER, orphanRemoval = true, mappedBy = "input")
+ private CalcDData data;
+
+ private final String name;
+
+ public CalcDInput(String name) {
+ this.name = name;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public CalcDData getData() {
+ return data;
+ }
+
+ public void setData(CalcDData data) {
+ this.data = data;
+ }
+}
diff --git a/ebean-core/src/test/java/org/tests/model/onetoone/calcd/TestOneToOnePrimaryKeyJoinMapping.java b/ebean-core/src/test/java/org/tests/model/onetoone/calcd/TestOneToOnePrimaryKeyJoinMapping.java
new file mode 100644
index 000000000..9e1aa68f0
--- /dev/null
+++ b/ebean-core/src/test/java/org/tests/model/onetoone/calcd/TestOneToOnePrimaryKeyJoinMapping.java
@@ -0,0 +1,26 @@
+package org.tests.model.onetoone.calcd;
+
+import io.ebean.DB;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class TestOneToOnePrimaryKeyJoinMapping {
+
+ @Test
+ public void test() {
+
+ CalcDInput inputs = new CalcDInput("input0");
+
+ CalcDData data = new CalcDData("data0");
+ inputs.setData(data);
+ inputs.save();
+
+ CalcDInput found = DB.find(CalcDInput.class, inputs.getId());
+
+ assertThat(found).isNotNull();
+ assertThat(found.getName()).isEqualTo("input0");
+ assertThat(found.getData().getName()).isEqualTo("data0");
+
+ }
+}
From 622a90c7d5dd27b2cb477df635611314e100688d Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Sun, 23 May 2021 23:00:34 +1200
Subject: [PATCH 058/111] No effective change - tidy whitespace in
TransactionManager
---
.../transaction/TransactionManager.java | 31 -------------------
1 file changed, 31 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java
index b71868e5d..0728eebac 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java
@@ -53,7 +53,6 @@ import java.util.concurrent.atomic.AtomicLong;
* Manages transactions.
*
* Keeps the Cache and Cluster in sync when transactions are committed.
- *
*/
public class TransactionManager implements SpiTransactionManager {
@@ -198,8 +197,6 @@ public class TransactionManager implements SpiTransactionManager {
this.txnMain = metricFactory.createTimedMetric("txn.main");
this.txnReadOnly = metricFactory.createTimedMetric("txn.readonly");
this.txnNamed = metricFactory.createTimedMetricMap("txn.named.");
- // Add gauges for db pool size
-
scopeManager.register(this);
}
@@ -304,20 +301,16 @@ public class TransactionManager implements SpiTransactionManager {
* There is a potential optimisation available when read committed is the default
* isolation level. If it is, then Connections used only for queries do not require
* commit or rollback but instead can just be put back into the pool via close().
- *
*
* If the Isolation level is higher (say SERIALIZABLE) then Connections used
* just for queries do need to be committed or rollback after the query.
- *
*/
OnQueryOnly initOnQueryOnly(OnQueryOnly dbPlatformOnQueryOnly) {
-
// first check for a system property 'override'
String systemPropertyValue = System.getProperty("ebean.transaction.onqueryonly");
if (systemPropertyValue != null) {
return OnQueryOnly.valueOf(systemPropertyValue.trim().toUpperCase());
}
-
// default to rollback if not defined on the platform
return dbPlatformOnQueryOnly == null ? OnQueryOnly.COMMIT : dbPlatformOnQueryOnly;
}
@@ -359,9 +352,7 @@ public class TransactionManager implements SpiTransactionManager {
* Wrap an externally supplied Connection with a known transaction id.
*/
private SpiTransaction wrapExternalConnection(String id, Connection c) {
-
ExternalJdbcTransaction t = new ExternalJdbcTransaction(id, true, c, this);
-
// set the default batch mode
t.setBatchMode(persistBatch);
t.setBatchOnCascade(persistBatchOnCascade);
@@ -409,7 +400,6 @@ public class TransactionManager implements SpiTransactionManager {
*/
@Override
public void notifyOfRollback(SpiTransaction transaction, Throwable cause) {
-
try {
if (txnLogger.isDebug()) {
String msg = transaction.getLogPrefix() + "Rollback";
@@ -418,7 +408,6 @@ public class TransactionManager implements SpiTransactionManager {
}
txnLogger.debug(msg);
}
-
} catch (Exception ex) {
logger.error("Error while notifying TransactionEventListener of rollback event", ex);
}
@@ -445,7 +434,6 @@ public class TransactionManager implements SpiTransactionManager {
}
private void formatThrowable(Throwable e, StringBuilder sb) {
-
sb.append(e.toString());
StackTraceElement[] stackTrace = e.getStackTrace();
if (stackTrace.length > 0) {
@@ -468,11 +456,9 @@ public class TransactionManager implements SpiTransactionManager {
if (txnLogger.isDebug()) {
txnLogger.debug(transaction.getLogPrefix() + "Commit");
}
-
PostCommitProcessing postCommit = new PostCommitProcessing(clusterManager, this, transaction);
postCommit.notifyLocalCache();
backgroundExecutor.execute(postCommit.backgroundNotify());
-
} catch (Exception ex) {
logger.error("NotifyOfCommit failed. L2 Cache potentially not notified.", ex);
}
@@ -488,7 +474,6 @@ public class TransactionManager implements SpiTransactionManager {
}
private void externalModificationEvent(TransactionEventTable tableEvents) {
-
TransactionEvent event = new TransactionEvent();
event.add(tableEvents);
@@ -501,25 +486,21 @@ public class TransactionManager implements SpiTransactionManager {
* Notify local BeanPersistListeners etc of events from another server in the cluster.
*/
public void remoteTransactionEvent(RemoteTransactionEvent remoteEvent) {
-
if (clusterLogger.isDebugEnabled()) {
clusterLogger.debug("processing {}", remoteEvent);
}
-
CacheChangeSet changeSet = new CacheChangeSet();
RemoteTableMod tableMod = remoteEvent.getRemoteTableMod();
if (tableMod != null) {
changeSet.addInvalidate(tableMod.getTables());
}
-
List tableIUDList = remoteEvent.getTableIUDList();
if (tableIUDList != null) {
for (TableIUD tableIUD : tableIUDList) {
beanDescriptorManager.cacheNotify(tableIUD, changeSet);
}
}
-
// note DeleteById is written as BeanPersistIds and getBeanPersistList()
// processes both Bean IUD and DeleteById
List beanPersistList = remoteEvent.getBeanPersistList();
@@ -528,7 +509,6 @@ public class TransactionManager implements SpiTransactionManager {
persistIds.notifyCache(changeSet);
}
}
-
changeSet.apply();
}
@@ -543,10 +523,8 @@ public class TransactionManager implements SpiTransactionManager {
* Prepare and then send/log the changeSet.
*/
void sendChangeLog(final ChangeSet changeSet) {
-
// can set userId, userIpAddress & userContext if desired
if (changeLogPrepare.prepare(changeSet)) {
-
if (changeLogAsync) {
// call the log method in background
backgroundExecutor.execute(() -> changeLogListener.log(changeSet));
@@ -653,9 +631,7 @@ public class TransactionManager implements SpiTransactionManager {
* Begin a scoped transaction.
*/
public ScopedTransaction beginScopedTransaction(TxScope txScope) {
-
txScope = initTxScope(txScope);
-
ScopedTransaction txnContainer = getActiveScoped();
boolean setToScope;
@@ -678,7 +654,6 @@ public class TransactionManager implements SpiTransactionManager {
if (nestedSavepoint && (type == TxType.REQUIRED || type == TxType.REQUIRES_NEW)) {
createTransaction = true;
transaction = createSavepoint(transaction, this);
-
} else {
createTransaction = isCreateNewTransaction(transaction, type);
if (createTransaction) {
@@ -748,32 +723,26 @@ public class TransactionManager implements SpiTransactionManager {
* Determine whether to create a new transaction or not.
*
* This will also potentially throw exceptions for MANDATORY and NEVER types.
- *
*/
private boolean isCreateNewTransaction(SpiTransaction current, TxType type) {
switch (type) {
case REQUIRED:
case SUPPORTS:
return current == null;
-
case REQUIRES_NEW:
return true;
-
case MANDATORY:
if (current == null) {
throw new PersistenceException("Transaction missing when MANDATORY");
}
return false;
-
case NEVER:
if (current != null) {
throw new PersistenceException("Transaction exists for Transactional NEVER");
}
return true; // always use NoTransaction instance
-
case NOT_SUPPORTED:
return true; // always use NoTransaction instance
-
default:
throw new RuntimeException("Should never get here?");
}
From 850f1c1469253ec0c680247724261bbd0388757a Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Sun, 23 May 2021 23:08:38 +1200
Subject: [PATCH 059/111] [maven-release-plugin] prepare release
ebean-parent-12.9.0
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 10e919049..e329d4f8e 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index 1c7d48b4e..d58436ad9 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.9.0
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index dc1478d34..26e65f569 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-api
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-core-type
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-ddl-generator
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-externalmapping-api
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-externalmapping-xml
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-autotune
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-querybean
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
querybean-generator
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
io.ebean
kotlin-querybean-generator
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
io.ebean
ebean-test
- 12.9.0-SNAPSHOT
+ 12.9.0
test
io.ebean
ebean-postgis
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-redis
- 12.9.0-SNAPSHOT
+ 12.9.0
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index e6589d839..c83c12657 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.9.0-SNAPSHOT
+ 12.9.0
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 16e400f91..294126146 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.9.0
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-core-type
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-externalmapping-api
- 12.9.0-SNAPSHOT
+ 12.9.0
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 6b16e9b2a..51d288d68 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index 57372b097..1858ca78a 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index 0fb961ac4..174af5f49 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.9.0
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.9.0-SNAPSHOT
+ 12.9.0
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
test
io.ebean
ebean-ddl-generator
- 12.9.0-SNAPSHOT
+ 12.9.0
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index e000db688..86ddf6ab5 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.9.0-SNAPSHOT
+ 12.9.0
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index 57b01e349..fe67071c0 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.9.0-SNAPSHOT
+ 12.9.0
test
io.ebean
querybean-generator
- 12.9.0-SNAPSHOT
+ 12.9.0
test
io.ebean
ebean-test
- 12.9.0-SNAPSHOT
+ 12.9.0
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index c500e7508..dd8d1d5bf 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
io.ebean
ebean-querybean
- 12.9.0-SNAPSHOT
+ 12.9.0
test
io.ebean
querybean-generator
- 12.9.0-SNAPSHOT
+ 12.9.0
test
io.ebean
ebean-test
- 12.9.0-SNAPSHOT
+ 12.9.0
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index 94cba52d6..cd17d895d 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
provided
io.ebean
ebean-ddl-generator
- 12.9.0-SNAPSHOT
+ 12.9.0
diff --git a/ebean/pom.xml b/ebean/pom.xml
index d284c0bda..510e0a78f 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
io.ebean
ebean-querybean
- 12.9.0-SNAPSHOT
+ 12.9.0
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 917d4275a..76d9c49de 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.9.0-SNAPSHOT
+ 12.9.0
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.9.0-SNAPSHOT
+ 12.9.0
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.9.0-SNAPSHOT
+ 12.9.0
test
diff --git a/pom.xml b/pom.xml
index 14f2e3f08..d96af125b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.9.0-SNAPSHOT
+ 12.9.0
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.9.0
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index d5d769ac4..4bbbd7cf6 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0-SNAPSHOT
+ 12.9.0
querybean generator
From 47bd2ff03d34128f069df13c6d3581b8a4b125aa Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Sun, 23 May 2021 23:08:47 +1200
Subject: [PATCH 060/111] [maven-release-plugin] prepare for next development
iteration
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index e329d4f8e..250066b16 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index d58436ad9..8aadc2cb8 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.9.0
+ ebean-parent-12.8.0
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 26e65f569..bc4b1c60d 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-api
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-core-type
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-ddl-generator
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-externalmapping-xml
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-autotune
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-querybean
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
querybean-generator
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
io.ebean
kotlin-querybean-generator
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
io.ebean
ebean-test
- 12.9.0
+ 12.9.1-SNAPSHOT
test
io.ebean
ebean-postgis
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-redis
- 12.9.0
+ 12.9.1-SNAPSHOT
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index c83c12657..2cc5360a1 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.9.0
+ 12.9.1-SNAPSHOT
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 294126146..582ea91a8 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.9.0
+ ebean-parent-12.8.0
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-core-type
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.9.0
+ 12.9.1-SNAPSHOT
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 51d288d68..548d4a6bb 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index 1858ca78a..e4fe48811 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index 174af5f49..7be57fd2c 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.9.0
+ ebean-parent-12.8.0
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.9.0
+ 12.9.1-SNAPSHOT
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
test
io.ebean
ebean-ddl-generator
- 12.9.0
+ 12.9.1-SNAPSHOT
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index 86ddf6ab5..837464a0b 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.9.0
+ 12.9.1-SNAPSHOT
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index fe67071c0..91a109c24 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.9.0
+ 12.9.1-SNAPSHOT
test
io.ebean
querybean-generator
- 12.9.0
+ 12.9.1-SNAPSHOT
test
io.ebean
ebean-test
- 12.9.0
+ 12.9.1-SNAPSHOT
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index dd8d1d5bf..e051ea21b 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
io.ebean
ebean-querybean
- 12.9.0
+ 12.9.1-SNAPSHOT
test
io.ebean
querybean-generator
- 12.9.0
+ 12.9.1-SNAPSHOT
test
io.ebean
ebean-test
- 12.9.0
+ 12.9.1-SNAPSHOT
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index cd17d895d..dbf417b93 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
provided
io.ebean
ebean-ddl-generator
- 12.9.0
+ 12.9.1-SNAPSHOT
diff --git a/ebean/pom.xml b/ebean/pom.xml
index 510e0a78f..ac9ee412e 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
io.ebean
ebean-querybean
- 12.9.0
+ 12.9.1-SNAPSHOT
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 76d9c49de..ab6342a77 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.9.0
+ 12.9.1-SNAPSHOT
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.9.0
+ 12.9.1-SNAPSHOT
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.9.0
+ 12.9.1-SNAPSHOT
test
diff --git a/pom.xml b/pom.xml
index d96af125b..fc8e0db25 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.9.0
+ 12.9.1-SNAPSHOT
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.9.0
+ ebean-parent-12.8.0
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index 4bbbd7cf6..3c6a182a2 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.0
+ 12.9.1-SNAPSHOT
querybean generator
From 16832ac67a3994ace10108caaaf9bd461b54ea71 Mon Sep 17 00:00:00 2001
From: Ben Kempe
Date: Mon, 24 May 2021 23:47:55 +0200
Subject: [PATCH 061/111] add test testSelectOneToOneDisjunction
---
.../joins/TestDisjunctWhereOuterJoin.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/ebean-core/src/test/java/org/tests/query/joins/TestDisjunctWhereOuterJoin.java b/ebean-core/src/test/java/org/tests/query/joins/TestDisjunctWhereOuterJoin.java
index 28b8b0dbd..5d895adbc 100644
--- a/ebean-core/src/test/java/org/tests/query/joins/TestDisjunctWhereOuterJoin.java
+++ b/ebean-core/src/test/java/org/tests/query/joins/TestDisjunctWhereOuterJoin.java
@@ -5,6 +5,7 @@ import io.ebean.Ebean;
import io.ebean.Expr;
import io.ebean.Query;
import org.junit.Test;
+import org.tests.basic.one2one.Wheel;
import org.tests.model.basic.MRole;
import org.tests.model.basic.MUser;
@@ -82,6 +83,24 @@ public class TestDisjunctWhereOuterJoin extends BaseTestCase {
assertThat(sql).contains("where (t0.user_name = ? or u1.roleid = ?)");
}
+ @Test
+ public void testSelectOneToOneDisjunction() {
+ Ebean.beginTransaction();
+ try {
+ Query query = Ebean.find(Wheel.class)
+ .select("id")
+ .where().or()
+ .ge("tire.id", 100)
+ .lt("tire.id", 100)
+ .endOr().query();
+ query.findList();
+ String sql = sqlOf(query);
+ assertThat(sql).contains("join");
+ } finally {
+ Ebean.rollbackTransaction();
+ }
+ }
+
private void queryOrExpression(Integer roleid) {
Query query = Ebean.find(MUser.class)
From bf2420702cfccc6c8c3321e44e693ad1b238cd9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20P=C3=B6hler?=
Date: Tue, 1 Jun 2021 17:19:38 +0200
Subject: [PATCH 062/111] FIX: set ddl-generator version to a repo-available
version
---
ebean-core/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 582ea91a8..accc9e877 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -72,7 +72,7 @@
io.ebean
ebean-ddl-generator
- 12.8.4a
+ 12.9.0
test
From 348c075a1478f1d92b3922b99ae0b4d264dbd8ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20P=C3=B6hler?=
Date: Tue, 1 Jun 2021 17:56:47 +0200
Subject: [PATCH 063/111] FIX: Build for java8
---
ebean-core/pom.xml | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index accc9e877..eabc9a68f 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -119,6 +119,15 @@
provided
+
+
+ com.h2database
+ h2
+ 1.4.199
+ provided
+
+
javax.transaction
jta
@@ -214,15 +223,6 @@
test
-
-
- com.h2database
- h2
- 1.4.199
- provided
-
-
org.xerial
sqlite-jdbc
From 6697aecd48e95fd461d2c97fc29f8455c325149a Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 4 Jun 2021 17:16:50 +1200
Subject: [PATCH 064/111] #2238 - Select with disjunction of expressions over
OneToOne relationship missing join clause
Noting that there might be a better fix. The addJoin() at line 151 is suppressed as it is a duplicate for this case of a !oneToOneExported so a better fix might be to only add the soft delete clause when the join as actually added (not suppressed as a duplicate).
---
.../ebeaninternal/server/query/SqlTreeNodeExtraJoin.java | 4 ++--
.../softdelete/TestSoftDeleteOptionalRelationship.java | 9 ++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java
index 7238224d7..1b31ee08c 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/SqlTreeNodeExtraJoin.java
@@ -143,13 +143,13 @@ class SqlTreeNodeExtraJoin implements SqlTreeNode {
// "promote" to left join as the path contains a many
joinType = SqlJoinType.OUTER;
}
- if (!manyToMany && !oneToOneExported) {
+ if (!manyToMany) {
if (assocBeanProperty.isFormula()) {
// add joins for formula beans
assocBeanProperty.appendFrom(ctx, joinType);
}
joinType = assocBeanProperty.addJoin(joinType, prefix, ctx);
- if (assocBeanProperty.isTargetSoftDelete() && temporalMode != SpiQuery.TemporalMode.SOFT_DELETED) {
+ if (!oneToOneExported && assocBeanProperty.isTargetSoftDelete() && temporalMode != SpiQuery.TemporalMode.SOFT_DELETED) {
ctx.append(" and ").append(assocBeanProperty.getSoftDeletePredicate(ctx.getTableAlias(prefix)));
}
}
diff --git a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java
index 2488060d4..b4e320b21 100644
--- a/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java
+++ b/ebean-core/src/test/java/org/tests/softdelete/TestSoftDeleteOptionalRelationship.java
@@ -3,12 +3,14 @@ package org.tests.softdelete;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
+import org.ebeantest.LoggedSqlCollector;
import org.tests.model.softdelete.ESoftDelMid;
import io.ebean.Finder;
import org.junit.Test;
import org.tests.model.softdelete.ESoftDelY;
import org.tests.model.softdelete.ESoftDelZ;
+import java.util.List;
import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
@@ -44,6 +46,8 @@ public class TestSoftDeleteOptionalRelationship extends BaseTestCase {
DB.save(y);
}
+ LoggedSqlCollector.start();
+
Finder finder = new Finder<>(ESoftDelY.class);
ESoftDelY bean = finder
.query()
@@ -53,7 +57,10 @@ public class TestSoftDeleteOptionalRelationship extends BaseTestCase {
.findOne();
assertThat(bean).isNotNull();
+
+ final List sql = LoggedSqlCollector.stop();
+ assertThat(sql).hasSize(1);
+ assertThat(sql.get(0)).contains("left join esoft_del_z t1 on t1.id = t0.organization_id and t1.deleted = false where");
}
-
}
From b189e67b4cf3040f48c98ffee7b0685b6eeba315 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 4 Jun 2021 17:35:19 +1200
Subject: [PATCH 065/111] #2241 - Offline DDL migration generation for H2
requires H2 Driver
---
.../dbmigration/ddlgeneration/platform/H2HistoryDdl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/H2HistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/H2HistoryDdl.java
index bb474c1e4..2e7f97e2c 100644
--- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/H2HistoryDdl.java
+++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/H2HistoryDdl.java
@@ -12,7 +12,7 @@ import java.io.IOException;
*/
public class H2HistoryDdl extends DbTriggerBasedHistoryDdl {
- private static final String TRIGGER_CLASS = H2HistoryTrigger.class.getName();
+ private static final String TRIGGER_CLASS = "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
H2HistoryDdl() {
this.sysPeriodType = "timestamp";
From c9120be347aadd413371d46f974b2aa41630fa96 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 4 Jun 2021 17:37:37 +1200
Subject: [PATCH 066/111] No effective change - tidy only H2HistoryTrigger and
H2HistoryDdl
---
.../config/dbplatform/h2/H2HistoryTrigger.java | 13 +++----------
.../ddlgeneration/platform/H2HistoryDdl.java | 7 -------
2 files changed, 3 insertions(+), 17 deletions(-)
diff --git a/ebean-api/src/main/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java b/ebean-api/src/main/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java
index 785e24a0c..323dd1120 100644
--- a/ebean-api/src/main/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java
+++ b/ebean-api/src/main/java/io/ebean/config/dbplatform/h2/H2HistoryTrigger.java
@@ -4,11 +4,7 @@ import org.h2.api.Trigger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Timestamp;
+import java.sql.*;
import java.util.Arrays;
/**
@@ -43,7 +39,6 @@ public class H2HistoryTrigger implements Trigger {
@Override
public void init(Connection conn, String schemaName, String triggerName, String tableName, boolean before, int type) throws SQLException {
-
// get the columns for the table
ResultSet rs = conn.getMetaData().getColumns(null, schemaName, tableName, null);
@@ -79,7 +74,6 @@ public class H2HistoryTrigger implements Trigger {
@Override
public void fire(Connection connection, Object[] oldRow, Object[] newRow) throws SQLException {
-
if (oldRow != null) {
// a delete or update event
Timestamp now = new Timestamp(System.currentTimeMillis());
@@ -99,7 +93,6 @@ public class H2HistoryTrigger implements Trigger {
* Insert the data into the history table.
*/
private void insertIntoHistory(Connection connection, Object[] oldRow) throws SQLException {
-
try (PreparedStatement stmt = connection.prepareStatement(insertHistorySql)) {
for (int i = 0; i < oldRow.length; i++) {
stmt.setObject(i + 1, oldRow[i]);
@@ -110,11 +103,11 @@ public class H2HistoryTrigger implements Trigger {
@Override
public void close() throws SQLException {
-
+ // do nothing
}
@Override
public void remove() throws SQLException {
-
+ // do nothing
}
}
diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/H2HistoryDdl.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/H2HistoryDdl.java
index 2e7f97e2c..5bd58adeb 100644
--- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/H2HistoryDdl.java
+++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/H2HistoryDdl.java
@@ -1,6 +1,5 @@
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
-import io.ebean.config.dbplatform.h2.H2HistoryTrigger;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite;
import io.ebeaninternal.dbmigration.model.MTable;
@@ -22,31 +21,25 @@ public class H2HistoryDdl extends DbTriggerBasedHistoryDdl {
@Override
protected void dropTriggers(DdlBuffer buffer, String baseTable) throws IOException {
-
buffer.append("drop trigger ").append(updateTriggerName(baseTable)).endOfStatement();
}
@Override
protected void createTriggers(DdlWrite writer, MTable table) throws IOException {
-
String baseTableName = table.getName();
DdlBuffer apply = writer.applyHistoryTrigger();
-
addCreateTrigger(apply, updateTriggerName(baseTableName), baseTableName);
}
@Override
protected void updateHistoryTriggers(DbTriggerUpdate update) throws IOException {
-
recreateHistoryView(update);
-
DdlBuffer buffer = update.historyTriggerBuffer();
dropTriggers(buffer, update.getBaseTable());
addCreateTrigger(buffer, updateTriggerName(update.getBaseTable()), update.getBaseTable());
}
private void addCreateTrigger(DdlBuffer apply, String triggerName, String baseTable) throws IOException {
-
// Note that this does not take into account the historyTable name (excepts _history suffix) and
// does not take into account excluded columns (all columns included in history)
apply
From ae4f50e7b3a1b15fe3a0f97a9ec01803518f72e7 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 4 Jun 2021 17:46:31 +1200
Subject: [PATCH 067/111] #2236 - Auto-tune does not work / throws
RuntimeException (Regression from 12.7.1)
Note we are missing a test on ProfileManager but doing this for now.
---
.../server/autotune/service/ProfileManager.java | 10 +---------
.../server/autotune/service/ProfileOriginTest.java | 10 +++++-----
.../ebeaninternal/server/querydefn/OrmQueryDetail.java | 2 +-
3 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileManager.java b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileManager.java
index f334208f9..170a3a406 100644
--- a/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileManager.java
+++ b/ebean-autotune/src/main/java/io/ebeaninternal/server/autotune/service/ProfileManager.java
@@ -46,7 +46,6 @@ public class ProfileManager implements ProfilingListener {
@Override
public boolean isProfileRequest(ObjectGraphNode origin, SpiQuery> query) {
-
ProfileOrigin profileOrigin = profileMap.get(origin.getOriginQueryPoint().getKey());
if (profileOrigin == null) {
profileMap.put(origin.getOriginQueryPoint().getKey(), createProfileOrigin(origin, query));
@@ -61,12 +60,11 @@ public class ProfileManager implements ProfilingListener {
*
* For new profiling entries it is useful to compare the profiling against the current
* query detail that is specified in the code (as the query might already be manually optimised).
- *
*/
private ProfileOrigin createProfileOrigin(ObjectGraphNode origin, SpiQuery> query) {
ProfileOrigin profileOrigin = new ProfileOrigin(origin.getOriginQueryPoint(), queryTuningAddVersion, profilingBase, profilingRate);
// set the current query detail (fetch group) so that we can compare against profiling for new entries
- profileOrigin.setOriginalQuery(query.getDetail().toString());
+ profileOrigin.setOriginalQuery(query.getDetail().asString());
return profileOrigin;
}
@@ -77,7 +75,6 @@ public class ProfileManager implements ProfilingListener {
*/
@Override
public void collectQueryInfo(ObjectGraphNode node, long beans, long micros) {
-
if (node != null) {
ObjectGraphOrigin origin = node.getOriginQueryPoint();
if (origin != null) {
@@ -92,11 +89,9 @@ public class ProfileManager implements ProfilingListener {
*
* This is sent to use from a EntityBeanIntercept when the finalise method
* is called on the bean.
- *
*/
@Override
public void collectNodeUsage(NodeUsageCollector usageCollector) {
-
ProfileOrigin profileOrigin = getProfileOrigin(usageCollector.getNode().getOriginQueryPoint());
profileOrigin.collectUsageInfo(usageCollector);
}
@@ -114,16 +109,13 @@ public class ProfileManager implements ProfilingListener {
* Collect all the profiling information.
*/
public AutoTuneCollection profilingCollection(boolean reset) {
-
AutoTuneCollection req = new AutoTuneCollection();
-
for (ProfileOrigin origin : profileMap.values()) {
BeanDescriptor> desc = server.getBeanDescriptorById(origin.getOrigin().getBeanType());
if (desc != null) {
origin.profilingCollection(desc, req, reset);
}
}
-
return req;
}
diff --git a/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java b/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java
index c3995d215..b1f982024 100644
--- a/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java
+++ b/ebean-autotune/src/test/java/io/ebeaninternal/server/autotune/service/ProfileOriginTest.java
@@ -27,7 +27,7 @@ public class ProfileOriginTest extends BaseTestCase {
OrmQueryDetail detail = po.buildDetail(desc);
- assertThat(detail.asStringDebug().trim()).isEqualTo("fetch customer (name)");
+ assertThat(detail.asString().trim()).isEqualTo("fetch customer (name)");
}
@Test
@@ -46,7 +46,7 @@ public class ProfileOriginTest extends BaseTestCase {
OrmQueryDetail detail = po.buildDetail(desc);
- assertThat(detail.asStringDebug()).isEqualTo("select (orderDate) fetch customer (name)");
+ assertThat(detail.asString()).isEqualTo("select (orderDate) fetch customer (name)");
}
@Test
@@ -64,7 +64,7 @@ public class ProfileOriginTest extends BaseTestCase {
OrmQueryDetail detail = po.buildDetail(desc);
- assertThat(detail.asStringDebug().trim()).isEqualTo("select (orderDate,customer)");
+ assertThat(detail.asString().trim()).isEqualTo("select (orderDate,customer)");
}
@Test
@@ -87,7 +87,7 @@ public class ProfileOriginTest extends BaseTestCase {
OrmQueryDetail detail = po.buildDetail(desc);
- assertThat(detail.asStringDebug()).isEqualTo("select (orderDate) fetch customer (billingAddress)");
+ assertThat(detail.asString()).isEqualTo("select (orderDate) fetch customer (billingAddress)");
}
@@ -116,7 +116,7 @@ public class ProfileOriginTest extends BaseTestCase {
po.collectUsageInfo(c);
OrmQueryDetail detail = po.buildDetail(desc);
- assertThat(detail.asStringDebug()).isEqualTo("fetch customer (name,note) fetch customer.billingAddress (line1)");
+ assertThat(detail.asString()).isEqualTo("fetch customer (name,note) fetch customer.billingAddress (line1)");
}
private NodeUsageCollector node(String path) {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
index 6646746eb..2fabfdd79 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/OrmQueryDetail.java
@@ -100,7 +100,7 @@ public class OrmQueryDetail implements Serializable {
/**
* Return the detail in string form.
*/
- public String asStringDebug() {
+ public String asString() {
StringBuilder sb = new StringBuilder();
if (baseProps.hasProperties()) {
baseProps.asStringDebug("select ", sb);
From ce5f1b25f5402f05cbc8f3dae311940fafc057f2 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 4 Jun 2021 17:50:46 +1200
Subject: [PATCH 068/111] Bump ebean-maven-plugin to 12.9.1
---
ebean-bom/pom.xml | 2 +-
ebean-core/pom.xml | 2 +-
ebean-ddl-generator/pom.xml | 2 +-
kotlin-querybean-generator/pom.xml | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index bc4b1c60d..1dfdafb52 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -19,7 +19,7 @@
4.1
7.0
12.9.0
- 12.9.0
+ 12.9.1
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index eabc9a68f..aad54f60e 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -302,7 +302,7 @@
io.ebean
ebean-maven-plugin
- 12.9.0
+ 12.9.1
test
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 548d4a6bb..3056cb064 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -76,7 +76,7 @@
io.ebean
ebean-maven-plugin
- 12.9.0
+ 12.9.1
test
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index ab6342a77..6e081b514 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -145,7 +145,7 @@
io.ebean
ebean-maven-plugin
- 12.9.0
+ 12.9.1
test
From 64405ade5204b20caeff42bfd00e1428f93bf0e5 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 4 Jun 2021 17:59:11 +1200
Subject: [PATCH 069/111] [maven-release-plugin] prepare release
ebean-parent-12.9.1
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 250066b16..286f7ae58 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index 8aadc2cb8..17084e262 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.9.1
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 1dfdafb52..5ea0b74cf 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-api
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-core-type
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-ddl-generator
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-externalmapping-api
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-externalmapping-xml
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-autotune
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-querybean
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
querybean-generator
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
io.ebean
kotlin-querybean-generator
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
io.ebean
ebean-test
- 12.9.1-SNAPSHOT
+ 12.9.1
test
io.ebean
ebean-postgis
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-redis
- 12.9.1-SNAPSHOT
+ 12.9.1
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index 2cc5360a1..d35cfa676 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.9.1-SNAPSHOT
+ 12.9.1
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index aad54f60e..1ba09d035 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.9.1
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-core-type
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-externalmapping-api
- 12.9.1-SNAPSHOT
+ 12.9.1
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 3056cb064..86f69ec5c 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index e4fe48811..1d69bcc30 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index 7be57fd2c..e4af2cc57 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.9.1
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.9.1-SNAPSHOT
+ 12.9.1
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
test
io.ebean
ebean-ddl-generator
- 12.9.1-SNAPSHOT
+ 12.9.1
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index 837464a0b..8352cef21 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.9.1-SNAPSHOT
+ 12.9.1
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index 91a109c24..fb83cca3e 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.9.1-SNAPSHOT
+ 12.9.1
test
io.ebean
querybean-generator
- 12.9.1-SNAPSHOT
+ 12.9.1
test
io.ebean
ebean-test
- 12.9.1-SNAPSHOT
+ 12.9.1
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index e051ea21b..61ee622d9 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
io.ebean
ebean-querybean
- 12.9.1-SNAPSHOT
+ 12.9.1
test
io.ebean
querybean-generator
- 12.9.1-SNAPSHOT
+ 12.9.1
test
io.ebean
ebean-test
- 12.9.1-SNAPSHOT
+ 12.9.1
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index dbf417b93..e35fd1d9f 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
provided
io.ebean
ebean-ddl-generator
- 12.9.1-SNAPSHOT
+ 12.9.1
diff --git a/ebean/pom.xml b/ebean/pom.xml
index ac9ee412e..0aacf1dc3 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
io.ebean
ebean-querybean
- 12.9.1-SNAPSHOT
+ 12.9.1
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 6e081b514..2b3522a64 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.9.1-SNAPSHOT
+ 12.9.1
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.9.1-SNAPSHOT
+ 12.9.1
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.9.1-SNAPSHOT
+ 12.9.1
test
diff --git a/pom.xml b/pom.xml
index fc8e0db25..05caa74f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.9.1-SNAPSHOT
+ 12.9.1
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.8.0
+ ebean-parent-12.9.1
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index 3c6a182a2..c30aae273 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1-SNAPSHOT
+ 12.9.1
querybean generator
From 612295fb9dee24a189d201daa6ff27fd8c82d166 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Fri, 4 Jun 2021 17:59:21 +1200
Subject: [PATCH 070/111] [maven-release-plugin] prepare for next development
iteration
---
ebean-api/pom.xml | 2 +-
ebean-autotune/pom.xml | 6 +++---
ebean-bom/pom.xml | 30 +++++++++++++++---------------
ebean-core-type/pom.xml | 4 ++--
ebean-core/pom.xml | 10 +++++-----
ebean-ddl-generator/pom.xml | 6 +++---
ebean-externalmapping-api/pom.xml | 2 +-
ebean-externalmapping-xml/pom.xml | 10 +++++-----
ebean-postgis/pom.xml | 6 +++---
ebean-querybean/pom.xml | 10 +++++-----
ebean-redis/pom.xml | 12 ++++++------
ebean-test/pom.xml | 6 +++---
ebean/pom.xml | 8 ++++----
kotlin-querybean-generator/pom.xml | 8 ++++----
pom.xml | 4 ++--
querybean-generator/pom.xml | 2 +-
16 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml
index 286f7ae58..1d382e05c 100644
--- a/ebean-api/pom.xml
+++ b/ebean-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean api
diff --git a/ebean-autotune/pom.xml b/ebean-autotune/pom.xml
index 17084e262..b8908e306 100644
--- a/ebean-autotune/pom.xml
+++ b/ebean-autotune/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.9.1
+ ebean-parent-12.8.0
ebean autotune
@@ -26,7 +26,7 @@
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 5ea0b74cf..94223e4be 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean bom
@@ -81,88 +81,88 @@
io.ebean
ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-api
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-core-type
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-ddl-generator
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-externalmapping-xml
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-autotune
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-querybean
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
querybean-generator
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
io.ebean
kotlin-querybean-generator
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
io.ebean
ebean-test
- 12.9.1
+ 12.9.2-SNAPSHOT
test
io.ebean
ebean-postgis
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-redis
- 12.9.1
+ 12.9.2-SNAPSHOT
diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml
index d35cfa676..d7ea19e6f 100644
--- a/ebean-core-type/pom.xml
+++ b/ebean-core-type/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean-core-type
@@ -16,7 +16,7 @@
io.ebean
ebean-api
- 12.9.1
+ 12.9.2-SNAPSHOT
diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml
index 1ba09d035..8f0b27243 100644
--- a/ebean-core/pom.xml
+++ b/ebean-core/pom.xml
@@ -3,7 +3,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean-core
@@ -15,7 +15,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.9.1
+ ebean-parent-12.8.0
@@ -87,19 +87,19 @@
io.ebean
ebean-api
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-core-type
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-externalmapping-api
- 12.9.1
+ 12.9.2-SNAPSHOT
diff --git a/ebean-ddl-generator/pom.xml b/ebean-ddl-generator/pom.xml
index 86f69ec5c..6397c239b 100644
--- a/ebean-ddl-generator/pom.xml
+++ b/ebean-ddl-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean ddl generation
@@ -28,14 +28,14 @@
io.ebean
ebean-core-type
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
diff --git a/ebean-externalmapping-api/pom.xml b/ebean-externalmapping-api/pom.xml
index 1d69bcc30..45e433741 100644
--- a/ebean-externalmapping-api/pom.xml
+++ b/ebean-externalmapping-api/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean external mapping api
diff --git a/ebean-externalmapping-xml/pom.xml b/ebean-externalmapping-xml/pom.xml
index e4af2cc57..17aa58fdb 100644
--- a/ebean-externalmapping-xml/pom.xml
+++ b/ebean-externalmapping-xml/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
@@ -14,7 +14,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.9.1
+ ebean-parent-12.8.0
ebean external mapping xml
@@ -33,7 +33,7 @@
io.ebean
ebean-externalmapping-api
- 12.9.1
+ 12.9.2-SNAPSHOT
@@ -59,14 +59,14 @@
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
test
io.ebean
ebean-ddl-generator
- 12.9.1
+ 12.9.2-SNAPSHOT
test
diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml
index 8352cef21..74ea548c1 100644
--- a/ebean-postgis/pom.xml
+++ b/ebean-postgis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean postgis
@@ -23,7 +23,7 @@
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
@@ -74,7 +74,7 @@
io.ebean
ebean-test
- 12.9.1
+ 12.9.2-SNAPSHOT
test
diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml
index fb83cca3e..2994c396d 100644
--- a/ebean-querybean/pom.xml
+++ b/ebean-querybean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean querybean
@@ -17,7 +17,7 @@
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
@@ -57,21 +57,21 @@
io.ebean
ebean-ddl-generator
- 12.9.1
+ 12.9.2-SNAPSHOT
test
io.ebean
querybean-generator
- 12.9.1
+ 12.9.2-SNAPSHOT
test
io.ebean
ebean-test
- 12.9.1
+ 12.9.2-SNAPSHOT
test
diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml
index 61ee622d9..12187d225 100644
--- a/ebean-redis/pom.xml
+++ b/ebean-redis/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean-redis
@@ -22,35 +22,35 @@
io.ebean
ebean-api
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
io.ebean
ebean-querybean
- 12.9.1
+ 12.9.2-SNAPSHOT
test
io.ebean
querybean-generator
- 12.9.1
+ 12.9.2-SNAPSHOT
test
io.ebean
ebean-test
- 12.9.1
+ 12.9.2-SNAPSHOT
test
diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml
index e35fd1d9f..66aeb2e78 100644
--- a/ebean-test/pom.xml
+++ b/ebean-test/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean test
@@ -29,14 +29,14 @@
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
provided
io.ebean
ebean-ddl-generator
- 12.9.1
+ 12.9.2-SNAPSHOT
diff --git a/ebean/pom.xml b/ebean/pom.xml
index 0aacf1dc3..c8f3462d4 100644
--- a/ebean/pom.xml
+++ b/ebean/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
ebean composite
@@ -22,20 +22,20 @@
io.ebean
ebean-api
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
io.ebean
ebean-querybean
- 12.9.1
+ 12.9.2-SNAPSHOT
diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml
index 2b3522a64..20bf130a3 100644
--- a/kotlin-querybean-generator/pom.xml
+++ b/kotlin-querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
kotlin querybean generator
@@ -29,7 +29,7 @@
io.ebean
ebean-querybean
- 12.9.1
+ 12.9.2-SNAPSHOT
test
@@ -43,7 +43,7 @@
io.ebean
ebean-core
- 12.9.1
+ 12.9.2-SNAPSHOT
test
@@ -64,7 +64,7 @@
io.ebean
ebean-ddl-generator
- 12.9.1
+ 12.9.2-SNAPSHOT
test
diff --git a/pom.xml b/pom.xml
index 05caa74f3..af7bc24b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
io.ebean
ebean-parent
- 12.9.1
+ 12.9.2-SNAPSHOT
pom
ebean parent
@@ -18,7 +18,7 @@
scm:git:git@github.com:ebean-orm/ebean.git
- ebean-parent-12.9.1
+ ebean-parent-12.8.0
diff --git a/querybean-generator/pom.xml b/querybean-generator/pom.xml
index c30aae273..1e59c8065 100644
--- a/querybean-generator/pom.xml
+++ b/querybean-generator/pom.xml
@@ -4,7 +4,7 @@
ebean-parent
io.ebean
- 12.9.1
+ 12.9.2-SNAPSHOT
querybean generator
From 4613f63c6613358656c9a4f2798f2ceb21b4b6f2 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Wed, 9 Jun 2021 12:57:56 +1200
Subject: [PATCH 071/111] Refactor internals DataReader remove
resetColumnPosition()
- Move the reset of position to the DataReader.next() method
- Tidy up use of wasNull() in RsetDataReader
---
.../java/io/ebean/core/type/DataReader.java | 2 -
.../server/core/AbstractSqlQueryRequest.java | 22 +++----
.../server/core/DtoQueryRequest.java | 5 +-
.../server/core/RelationalQueryRequest.java | 5 ++
.../io/ebeaninternal/server/query/CQuery.java | 4 --
.../query/CQueryFetchSingleAttribute.java | 1 -
.../server/type/RsetDataReader.java | 57 +++----------------
7 files changed, 25 insertions(+), 71 deletions(-)
diff --git a/ebean-core-type/src/main/java/io/ebean/core/type/DataReader.java b/ebean-core-type/src/main/java/io/ebean/core/type/DataReader.java
index 45fba0e0e..a8ace12be 100644
--- a/ebean-core-type/src/main/java/io/ebean/core/type/DataReader.java
+++ b/ebean-core-type/src/main/java/io/ebean/core/type/DataReader.java
@@ -11,8 +11,6 @@ public interface DataReader {
boolean next() throws SQLException;
- void resetColumnPosition();
-
void incrementPos(int increment);
byte[] getBinaryBytes() throws SQLException;
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java
index c12534146..3c1050faf 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/AbstractSqlQueryRequest.java
@@ -1,13 +1,8 @@
package io.ebeaninternal.server.core;
-import io.ebean.EbeanServer;
import io.ebean.Transaction;
import io.ebean.util.JdbcClose;
-import io.ebeaninternal.api.BindParams;
-import io.ebeaninternal.api.SpiEbeanServer;
-import io.ebeaninternal.api.SpiQuery;
-import io.ebeaninternal.api.SpiSqlBinding;
-import io.ebeaninternal.api.SpiTransaction;
+import io.ebeaninternal.api.*;
import io.ebeaninternal.server.lib.Str;
import io.ebeaninternal.server.persist.Binder;
import io.ebeaninternal.server.persist.TrimLogSql;
@@ -83,11 +78,6 @@ public abstract class AbstractSqlQueryRequest {
return transaction.isLogSql();
}
- /**
- * Set the resultSet and associated query plan if known.
- */
- abstract void setResultSet(ResultSet resultSet, Object queryPlanKey) throws SQLException;
-
/**
* Return the bindLog for this request.
*/
@@ -95,12 +85,15 @@ public abstract class AbstractSqlQueryRequest {
return bindLog;
}
+ /**
+ * Set the resultSet and associated query plan if known.
+ */
+ abstract void setResultSet(ResultSet resultSet, Object queryPlanKey) throws SQLException;
+
/**
* Return true if we can navigate to the next row.
*/
- public boolean next() throws SQLException {
- return resultSet.next();
- }
+ public abstract boolean next() throws SQLException;
protected abstract void requestComplete();
@@ -113,7 +106,6 @@ public abstract class AbstractSqlQueryRequest {
JdbcClose.close(pstmt);
}
-
/**
* Prepare the SQL taking into account named bind parameters.
*/
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java
index 2372ed7c3..b988c83b5 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/DtoQueryRequest.java
@@ -110,9 +110,12 @@ public final class DtoQueryRequest extends AbstractSqlQueryRequest {
return queryEngine.findList(this);
}
+ public boolean next() throws SQLException {
+ return dataReader.next();
+ }
+
@SuppressWarnings("unchecked")
public T readNextBean() throws SQLException {
- dataReader.resetColumnPosition();
return (T) plan.readRow(dataReader);
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java
index 7850139c7..9f1413031 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java
@@ -139,6 +139,11 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest {
rows++;
}
+ @Override
+ public boolean next() throws SQLException {
+ return resultSet.next();
+ }
+
public List mapList(RowMapper mapper) throws SQLException {
List list = new ArrayList<>();
while (next()) {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java
index 9f30e9a29..49182242e 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQuery.java
@@ -486,14 +486,11 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran
* Return true if we can move to the next resultSet row.
*/
private boolean moveToNextRow() throws SQLException {
-
if (!dataReader.next()) {
noMoreRows = true;
return false;
}
-
rowCount++;
- dataReader.resetColumnPosition();
return true;
}
@@ -502,7 +499,6 @@ public class CQuery implements DbReadContext, CancelableQuery, SpiProfileTran
}
boolean readBean() throws SQLException {
-
boolean result = hasNext();
updateExecutionStatistics();
return result;
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryFetchSingleAttribute.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryFetchSingleAttribute.java
index 45fabfde7..9fd7278cc 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryFetchSingleAttribute.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryFetchSingleAttribute.java
@@ -111,7 +111,6 @@ class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent {
value = new CountedValue<>(value, dataReader.getLong());
}
result.add(value);
- dataReader.resetColumnPosition();
rowCount++;
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/RsetDataReader.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/RsetDataReader.java
index 3448251d5..9763a5667 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/RsetDataReader.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/RsetDataReader.java
@@ -43,12 +43,8 @@ public class RsetDataReader implements DataReader {
@Override
public boolean next() throws SQLException {
- return rset.next();
- }
-
- @Override
- public void resetColumnPosition() {
pos = 0;
+ return rset.next();
}
@Override
@@ -75,7 +71,6 @@ public class RsetDataReader implements DataReader {
return rset.getBigDecimal(pos());
}
-
@Override
public InputStream getBinaryStream() throws SQLException {
return rset.getBinaryStream(pos());
@@ -84,19 +79,13 @@ public class RsetDataReader implements DataReader {
@Override
public Boolean getBoolean() throws SQLException {
boolean v = rset.getBoolean(pos());
- if (rset.wasNull()) {
- return null;
- }
- return v;
+ return rset.wasNull() ? null : v;
}
@Override
public Byte getByte() throws SQLException {
byte v = rset.getByte(pos());
- if (rset.wasNull()) {
- return null;
- }
- return v;
+ return rset.wasNull() ? null : v;
}
@Override
@@ -117,62 +106,42 @@ public class RsetDataReader implements DataReader {
@Override
public Double getDouble() throws SQLException {
double v = rset.getDouble(pos());
- if (rset.wasNull()) {
- return null;
- }
- return v;
+ return rset.wasNull() ? null : v;
}
@Override
public Float getFloat() throws SQLException {
float v = rset.getFloat(pos());
- if (rset.wasNull()) {
- return null;
- }
- return v;
+ return rset.wasNull() ? null : v;
}
@Override
public Integer getInt() throws SQLException {
int v = rset.getInt(pos());
- if (rset.wasNull()) {
- return null;
- }
- return v;
+ return rset.wasNull() ? null : v;
}
-
@Override
public Long getLong() throws SQLException {
long v = rset.getLong(pos());
- if (rset.wasNull()) {
- return null;
- }
- return v;
+ return rset.wasNull() ? null : v;
}
-
public Ref getRef() throws SQLException {
return rset.getRef(pos());
}
-
@Override
public Short getShort() throws SQLException {
short s = rset.getShort(pos());
- if (rset.wasNull()) {
- return null;
- }
- return s;
+ return rset.wasNull() ? null : s;
}
-
@Override
public String getString() throws SQLException {
return rset.getString(pos());
}
-
@Override
public Time getTime() throws SQLException {
Calendar cal = dataTimeZone.getTimeZone();
@@ -196,14 +165,10 @@ public class RsetDataReader implements DataReader {
@Override
public String getStringFromStream() throws SQLException {
Reader reader = rset.getCharacterStream(pos());
- if (reader == null) {
- return null;
- }
- return readStringLob(reader);
+ return reader == null ? null : readStringLob(reader);
}
protected String readStringLob(Reader reader) throws SQLException {
-
char[] buffer = new char[clobBufferSize];
int readLength;
StringBuilder out = new StringBuilder(stringInitialSize);
@@ -215,7 +180,6 @@ public class RsetDataReader implements DataReader {
} catch (IOException e) {
throw new SQLException("IOException reading Clob " + e.getMessage());
}
-
return out.toString();
}
@@ -226,19 +190,16 @@ public class RsetDataReader implements DataReader {
}
protected byte[] getBinaryLob(InputStream in) throws SQLException {
-
if (in == null) {
return null;
}
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
-
byte[] buf = new byte[bufferSize];
int len;
while ((len = in.read(buf, 0, buf.length)) != -1) {
out.write(buf, 0, len);
}
byte[] data = out.toByteArray();
-
if (data.length == 0) {
data = null;
}
From 3add4472ef09f101fca17384ff523c98f070e77d Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Wed, 9 Jun 2021 14:58:08 +1200
Subject: [PATCH 072/111] Refactor internals
DefaultRelationalQueryEngine.findListMapper()
- Remove findListMapper() method
- Introduce RowReader interface
- Combine findList internals for both SqlRow and RowMapper use
---
.../server/core/RelationalQueryEngine.java | 11 +-
.../server/core/RelationalQueryRequest.java | 31 ++----
.../ebeaninternal/server/core/RowReader.java | 14 +++
.../query/DefaultRelationalQueryEngine.java | 105 ++++++------------
.../querydefn/DefaultRelationalQuery.java | 19 +++-
.../tests/query/sqlquery/SqlQueryTests.java | 3 +-
6 files changed, 76 insertions(+), 107 deletions(-)
create mode 100644 ebean-core/src/main/java/io/ebeaninternal/server/core/RowReader.java
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryEngine.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryEngine.java
index 40f6d1a3c..86a439def 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryEngine.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryEngine.java
@@ -20,17 +20,17 @@ public interface RelationalQueryEngine {
/**
* Find a list of beans using relational query.
*/
- List findList(RelationalQueryRequest request);
+ List findList(RelationalQueryRequest request, RowReader reader);
/**
* Find each query using relational query.
*/
- void findEach(RelationalQueryRequest request, Consumer consumer);
+ void findEach(RelationalQueryRequest request, RowReader reader, Consumer consumer);
/**
* Find each while query using relational query.
*/
- void findEach(RelationalQueryRequest request, Predicate consumer);
+ void findEach(RelationalQueryRequest request, RowReader reader, Predicate consumer);
/**
* Find single attribute.
@@ -47,11 +47,6 @@ public interface RelationalQueryEngine {
*/
T findOneMapper(RelationalQueryRequest request, RowMapper mapper);
- /**
- * Find list via mapper.
- */
- List findListMapper(RelationalQueryRequest request, RowMapper mapper);
-
/**
* Find each via raw consumer.
*/
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java
index 9f1413031..c0371e546 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/RelationalQueryRequest.java
@@ -1,10 +1,6 @@
package io.ebeaninternal.server.core;
-import io.ebean.RowConsumer;
-import io.ebean.RowMapper;
-import io.ebean.SqlQuery;
-import io.ebean.SqlRow;
-import io.ebean.Transaction;
+import io.ebean.*;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiSqlBinding;
@@ -63,7 +59,7 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest {
List findListMapper(RowMapper mapper) {
flushJdbcBatchOnQuery();
- return queryEngine.findListMapper(this, mapper);
+ return queryEngine.findList(this, () -> mapper.map(resultSet, rows++));
}
T findOneMapper(RowMapper mapper) {
@@ -83,17 +79,17 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest {
public void findEach(Consumer consumer) {
flushJdbcBatchOnQuery();
- queryEngine.findEach(this, consumer);
+ queryEngine.findEach(this, this::createNewRow, consumer);
}
public void findEachWhile(Predicate consumer) {
flushJdbcBatchOnQuery();
- queryEngine.findEach(this, consumer);
+ queryEngine.findEach(this, this::createNewRow, consumer);
}
public List findList() {
flushJdbcBatchOnQuery();
- return queryEngine.findList(this);
+ return queryEngine.findList(this, this::createNewRow);
}
/**
@@ -135,21 +131,14 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest {
return resultSet;
}
- public void incrementRows() {
- rows++;
- }
-
@Override
public boolean next() throws SQLException {
- return resultSet.next();
- }
-
- public List mapList(RowMapper mapper) throws SQLException {
- List list = new ArrayList<>();
- while (next()) {
- list.add(mapper.map(resultSet, rows++));
+ if (!resultSet.next()) {
+ return false;
+ } else {
+ rows++;
+ return true;
}
- return list;
}
public T mapOne(RowMapper mapper) throws SQLException {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/core/RowReader.java b/ebean-core/src/main/java/io/ebeaninternal/server/core/RowReader.java
new file mode 100644
index 000000000..2a7d0b119
--- /dev/null
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/core/RowReader.java
@@ -0,0 +1,14 @@
+package io.ebeaninternal.server.core;
+
+import java.sql.SQLException;
+
+/**
+ * Read a row building a result for that row.
+ */
+public interface RowReader {
+
+ /**
+ * Build and return a result for a row.
+ */
+ T read() throws SQLException;
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultRelationalQueryEngine.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultRelationalQueryEngine.java
index f49df1d20..655c0863a 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultRelationalQueryEngine.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/DefaultRelationalQueryEngine.java
@@ -3,6 +3,7 @@ package io.ebeaninternal.server.query;
import io.ebean.RowConsumer;
import io.ebean.RowMapper;
import io.ebean.SqlRow;
+import io.ebean.core.type.DataReader;
import io.ebean.core.type.ScalarType;
import io.ebean.meta.MetricVisitor;
import io.ebean.metric.MetricFactory;
@@ -10,10 +11,10 @@ import io.ebean.metric.TimedMetricMap;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.server.core.RelationalQueryEngine;
import io.ebeaninternal.server.core.RelationalQueryRequest;
+import io.ebeaninternal.server.core.RowReader;
import io.ebeaninternal.server.persist.Binder;
import javax.persistence.PersistenceException;
-import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
@@ -59,12 +60,11 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine {
}
@Override
- public void findEach(RelationalQueryRequest request, Predicate consumer) {
-
+ public void findEach(RelationalQueryRequest request, RowReader reader, Predicate consumer) {
try {
request.executeSql(binder, SpiQuery.Type.ITERATE);
while (request.next()) {
- if (!consumer.test(readRow(request))) {
+ if (!consumer.test(reader.read())) {
break;
}
}
@@ -79,12 +79,11 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine {
}
@Override
- public void findEach(RelationalQueryRequest request, Consumer consumer) {
-
+ public void findEach(RelationalQueryRequest request, RowReader reader, Consumer consumer) {
try {
request.executeSql(binder, SpiQuery.Type.ITERATE);
while (request.next()) {
- consumer.accept(readRow(request));
+ consumer.accept(reader.read());
}
request.logSummary();
@@ -112,22 +111,6 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine {
}
}
- @Override
- public List findListMapper(RelationalQueryRequest request, RowMapper mapper) {
- try {
- request.executeSql(binder, SpiQuery.Type.LIST);
- List list = request.mapList(mapper);
- request.logSummary();
- return list;
-
- } catch (Exception e) {
- throw new PersistenceException(errMsg(e.getMessage(), request.getSql()), e);
-
- } finally {
- request.close();
- }
- }
-
@Override
public void findEachRow(RelationalQueryRequest request, RowConsumer consumer) {
try {
@@ -143,51 +126,17 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine {
}
}
- @SuppressWarnings("unchecked")
- @Override
- public List findSingleAttributeList(RelationalQueryRequest request, Class cls) {
- ScalarType scalarType = (ScalarType) binder.getScalarType(cls);
- return findScalarList(request, scalarType);
- }
-
- private List findScalarList(RelationalQueryRequest request, ScalarType scalarType) {
- try {
- request.executeSql(binder, SpiQuery.Type.ATTRIBUTE);
- List list = new ArrayList<>();
- while (request.next()) {
- request.incrementRows();
- list.add(scalarType.read(binder.createDataReader(request.getResultSet())));
- }
-
- request.logSummary();
- return list;
-
- } catch (Exception e) {
- throw new PersistenceException(errMsg(e.getMessage(), request.getSql()), e);
-
- } finally {
- request.close();
- }
- }
-
@SuppressWarnings("unchecked")
@Override
public T findSingleAttribute(RelationalQueryRequest request, Class cls) {
-
ScalarType scalarType = (ScalarType) binder.getScalarType(cls);
- return findScalar(request, scalarType);
- }
-
- private T findScalar(RelationalQueryRequest request, ScalarType scalarType) {
try {
request.executeSql(binder, SpiQuery.Type.ATTRIBUTE);
-
+ final DataReader dataReader = binder.createDataReader(request.getResultSet());
T value = null;
- if (request.next()) {
- request.incrementRows();
- value = scalarType.read(binder.createDataReader(request.getResultSet()));
+ if (dataReader.next()) {
+ value = scalarType.read(dataReader);
}
-
request.logSummary();
return value;
@@ -199,16 +148,17 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine {
}
}
+ @SuppressWarnings("unchecked")
@Override
- public List findList(RelationalQueryRequest request) {
-
+ public List findSingleAttributeList(RelationalQueryRequest request, Class cls) {
+ ScalarType scalarType = (ScalarType) binder.getScalarType(cls);
try {
- request.executeSql(binder, SpiQuery.Type.LIST);
- List rows = new ArrayList<>();
- while (request.next()) {
- rows.add(readRow(request));
+ request.executeSql(binder, SpiQuery.Type.ATTRIBUTE);
+ final DataReader dataReader = binder.createDataReader(request.getResultSet());
+ List rows = new ArrayList<>();
+ while (dataReader.next()) {
+ rows.add(scalarType.read(dataReader));
}
-
request.logSummary();
return rows;
@@ -220,11 +170,22 @@ public class DefaultRelationalQueryEngine implements RelationalQueryEngine {
}
}
- /**
- * Read the row from the ResultSet and return as a MapBean.
- */
- private SqlRow readRow(RelationalQueryRequest request) throws SQLException {
- return request.createNewRow();
+ @Override
+ public List findList(RelationalQueryRequest request, RowReader reader) {
+ try {
+ request.executeSql(binder, SpiQuery.Type.LIST);
+ List rows = new ArrayList<>();
+ while (request.next()) {
+ rows.add(reader.read());
+ }
+ request.logSummary();
+ return rows;
+ } catch (Exception e) {
+ throw new PersistenceException(errMsg(e.getMessage(), request.getSql()), e);
+
+ } finally {
+ request.close();
+ }
}
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultRelationalQuery.java b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultRelationalQuery.java
index ec5b3c01a..4cf446d0f 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultRelationalQuery.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/querydefn/DefaultRelationalQuery.java
@@ -23,9 +23,9 @@ public class DefaultRelationalQuery implements SpiSqlQuery {
private final transient SpiEbeanServer server;
- private String label;
+ private final String query;
- private String query;
+ private String label;
private int firstRow;
@@ -208,19 +208,25 @@ public class DefaultRelationalQuery implements SpiSqlQuery {
return query;
}
- T mapperFindOne(RowMapper mapper) {
+ private T mapperFindOne(RowMapper mapper) {
return server.findOneMapper(this, mapper);
}
- List mapperFindList(RowMapper mapper) {
+ private List mapperFindList(RowMapper mapper) {
return server.findListMapper(this, mapper);
}
+ private void mapperFindEach(RowMapper mapper, Consumer consumer) {
+ server.findEachRow(this, (resultSet, rowNum) -> consumer.accept(mapper.map(resultSet, rowNum)));
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
@Override
public