diff --git a/composites/ebean-clickhouse/pom.xml b/composites/ebean-clickhouse/pom.xml index 06d7b16a7..8f543acfd 100644 --- a/composites/ebean-clickhouse/pom.xml +++ b/composites/ebean-clickhouse/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-clickhouse - 14.0.1 + 14.0.2 diff --git a/composites/ebean-cockroach/pom.xml b/composites/ebean-cockroach/pom.xml index 20acfa443..a4ff24d15 100644 --- a/composites/ebean-cockroach/pom.xml +++ b/composites/ebean-cockroach/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-postgres - 14.0.1 + 14.0.2 diff --git a/composites/ebean-db2/pom.xml b/composites/ebean-db2/pom.xml index 18567b46d..75994cb42 100644 --- a/composites/ebean-db2/pom.xml +++ b/composites/ebean-db2/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-db2 - 14.0.1 + 14.0.2 diff --git a/composites/ebean-h2/pom.xml b/composites/ebean-h2/pom.xml index e99c020f1..1ea2f32d5 100644 --- a/composites/ebean-h2/pom.xml +++ b/composites/ebean-h2/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-h2 - 14.0.1 + 14.0.2 diff --git a/composites/ebean-hana/pom.xml b/composites/ebean-hana/pom.xml index 1bbc036c2..2a41a2c87 100644 --- a/composites/ebean-hana/pom.xml +++ b/composites/ebean-hana/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-hana - 14.0.1 + 14.0.2 diff --git a/composites/ebean-mariadb/pom.xml b/composites/ebean-mariadb/pom.xml index 5e6bd20d8..2d2f14801 100644 --- a/composites/ebean-mariadb/pom.xml +++ b/composites/ebean-mariadb/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-mariadb - 14.0.1 + 14.0.2 diff --git a/composites/ebean-mysql/pom.xml b/composites/ebean-mysql/pom.xml index cac8d8a9f..6d7dd883f 100644 --- a/composites/ebean-mysql/pom.xml +++ b/composites/ebean-mysql/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-mysql - 14.0.1 + 14.0.2 diff --git a/composites/ebean-nuodb/pom.xml b/composites/ebean-nuodb/pom.xml index 1b1fb3857..64b0bf1da 100644 --- a/composites/ebean-nuodb/pom.xml +++ b/composites/ebean-nuodb/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-nuodb - 14.0.1 + 14.0.2 diff --git a/composites/ebean-oracle/pom.xml b/composites/ebean-oracle/pom.xml index 34a27740d..38098ef6f 100644 --- a/composites/ebean-oracle/pom.xml +++ b/composites/ebean-oracle/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-oracle - 14.0.1 + 14.0.2 diff --git a/composites/ebean-postgis/pom.xml b/composites/ebean-postgis/pom.xml index f360523d7..c325f6963 100644 --- a/composites/ebean-postgis/pom.xml +++ b/composites/ebean-postgis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -22,13 +22,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -47,19 +47,19 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-postgres - 14.0.1 + 14.0.2 io.ebean ebean-postgis-types - 14.0.1 + 14.0.2 diff --git a/composites/ebean-postgres/pom.xml b/composites/ebean-postgres/pom.xml index 48650fbd4..dd2e8a253 100644 --- a/composites/ebean-postgres/pom.xml +++ b/composites/ebean-postgres/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-postgres - 14.0.1 + 14.0.2 diff --git a/composites/ebean-sqlite/pom.xml b/composites/ebean-sqlite/pom.xml index e8ba4b984..fc51534f5 100644 --- a/composites/ebean-sqlite/pom.xml +++ b/composites/ebean-sqlite/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-sqlite - 14.0.1 + 14.0.2 diff --git a/composites/ebean-sqlserver/pom.xml b/composites/ebean-sqlserver/pom.xml index adcfe732c..03e19ad97 100644 --- a/composites/ebean-sqlserver/pom.xml +++ b/composites/ebean-sqlserver/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-sqlserver - 14.0.1 + 14.0.2 diff --git a/composites/ebean-yugabyte/pom.xml b/composites/ebean-yugabyte/pom.xml index 3ef2e2c3a..400ddd9a7 100644 --- a/composites/ebean-yugabyte/pom.xml +++ b/composites/ebean-yugabyte/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -42,13 +42,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-postgres - 14.0.1 + 14.0.2 diff --git a/composites/ebean/pom.xml b/composites/ebean/pom.xml index f37e439d6..ebcbe0a23 100644 --- a/composites/ebean/pom.xml +++ b/composites/ebean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -17,13 +17,13 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 @@ -41,7 +41,7 @@ io.ebean ebean-jackson-mapper - 14.0.1 + 14.0.2 @@ -60,13 +60,13 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean ebean-platform-all - 14.0.1 + 14.0.2 diff --git a/composites/pom.xml b/composites/pom.xml index b16cabddb..fa7d7178b 100644 --- a/composites/pom.xml +++ b/composites/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 composites diff --git a/ebean-api/pom.xml b/ebean-api/pom.xml index e2020d174..03656a18f 100644 --- a/ebean-api/pom.xml +++ b/ebean-api/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ebean api diff --git a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java index bcd228c75..fbbda0875 100644 --- a/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java +++ b/ebean-api/src/main/java/io/ebean/DatabaseBuilder.java @@ -2165,6 +2165,15 @@ public interface DatabaseBuilder { @Deprecated DatabaseBuilder setLoadModuleInfo(boolean loadModuleInfo); + /** + * Set if generated SQL SELECT should include the query label as an + * inline SQL comment (to help reference back from the SQL to the code + * that executed the query. + * + * @param includeLabelInSql When true include a SQL inline comment in generated SELECT queries. + */ + DatabaseConfig includeLabelInSql(boolean includeLabelInSql); + /** * Set the naming convention to apply to metrics names. */ @@ -3040,6 +3049,12 @@ public interface DatabaseBuilder { */ boolean isLoadModuleInfo(); + /** + * Return true if generated sql select query should include an inline sql comment with the + * query label or profile location label. + */ + boolean isIncludeLabelInSql(); + /** * Return the naming convention to apply to metrics names. */ diff --git a/ebean-api/src/main/java/io/ebean/Query.java b/ebean-api/src/main/java/io/ebean/Query.java index 0c78f1e11..47d9a92af 100644 --- a/ebean-api/src/main/java/io/ebean/Query.java +++ b/ebean-api/src/main/java/io/ebean/Query.java @@ -1528,6 +1528,14 @@ public interface Query extends CancelableQuery { */ Query setLabel(String label); + /** + * Set a SQL query hint. + *

+ * This results in an inline comment that immediately follows + * after the select keyword in the form: {@code /*+ hint *\/ } + */ + Query setHint(String hint); + /** * When set to true when you want the returned beans to be read only. */ diff --git a/ebean-api/src/main/java/io/ebean/config/ContainerConfig.java b/ebean-api/src/main/java/io/ebean/config/ContainerConfig.java index 20c05c27d..78ef262db 100644 --- a/ebean-api/src/main/java/io/ebean/config/ContainerConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/ContainerConfig.java @@ -1,8 +1,5 @@ package io.ebean.config; -import io.avaje.config.Config; -import io.avaje.config.Configuration; - import java.util.Properties; /** @@ -19,16 +16,6 @@ public class ContainerConfig { private String podName; private int port; private Properties properties; - private Configuration configuration; - - public ContainerConfig() { - this.configuration = Config.asConfiguration(); - this.active = configuration.getBool("ebean.cluster.active", active); - this.serviceName = configuration.getNullable("ebean.cluster.serviceName", serviceName); - this.namespace = configuration.getNullable("ebean.cluster.namespace", namespace); - this.podName = configuration.getNullable("ebean.cluster.podName", podName); - this.port = configuration.getInt("ebean.cluster.port", 0); - } /** * Return the service name. @@ -104,7 +91,7 @@ public class ContainerConfig { * Return the deployment properties. */ public Properties getProperties() { - return properties != null ? properties : configuration.asProperties(); + return properties; } /** @@ -114,4 +101,25 @@ public class ContainerConfig { this.properties = properties; } + /** + * Load the settings from properties. + */ + public void loadFromProperties(Properties properties) { + this.properties = properties; + this.active = getProperty(properties, "ebean.cluster.active", active); + this.serviceName = properties.getProperty("ebean.cluster.serviceName", serviceName); + this.namespace = properties.getProperty("ebean.cluster.namespace", namespace); + this.podName = properties.getProperty("ebean.cluster.podName", podName); + String portParam = properties.getProperty("ebean.cluster.port"); + if (portParam != null) { + this.port = Integer.parseInt(portParam); + } + } + + /** + * Return the boolean property setting. + */ + protected boolean getProperty(Properties properties, String key, boolean defaultValue) { + return "true".equalsIgnoreCase(properties.getProperty(key, Boolean.toString(defaultValue))); + } } 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 38dc0b5f9..e2fad2416 100644 --- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java +++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java @@ -123,6 +123,12 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { */ private boolean loadModuleInfo = true; + /** + * When true then include a sql comment in generated SELECT queries with the query + * label or profile location label. + */ + private boolean includeLabelInSql; + /** * Interesting classes such as entities, embedded, ScalarTypes, * Listeners, Finders, Controllers, AttributeConverters etc. @@ -2063,6 +2069,7 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { readOnlyDatabase = p.getBoolean("readOnlyDatabase", readOnlyDatabase); autoPersistUpdates = p.getBoolean("autoPersistUpdates", autoPersistUpdates); loadModuleInfo = p.getBoolean("loadModuleInfo", loadModuleInfo); + includeLabelInSql = p.getBoolean("includeLabelInSql", includeLabelInSql); maxCallStack = p.getInt("maxCallStack", maxCallStack); dumpMetricsOnShutdown = p.getBoolean("dumpMetricsOnShutdown", dumpMetricsOnShutdown); dumpMetricsOptions = p.get("dumpMetricsOptions", dumpMetricsOptions); @@ -2476,6 +2483,11 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { return loadModuleInfo; } + @Override + public boolean isIncludeLabelInSql() { + return includeLabelInSql; + } + /** * @deprecated - migrate to {@link #isLoadModuleInfo()}. */ @@ -2492,6 +2504,12 @@ public class DatabaseConfig implements DatabaseBuilder.Settings { return this; } + @Override + public DatabaseConfig includeLabelInSql(boolean includeLabelInSql) { + this.includeLabelInSql = includeLabelInSql; + return this; + } + @Override public Function getMetricNaming() { return metricNaming; diff --git a/ebean-api/src/main/java/io/ebean/config/dbplatform/DatabasePlatform.java b/ebean-api/src/main/java/io/ebean/config/dbplatform/DatabasePlatform.java index 5c4f33cc1..29b554c48 100644 --- a/ebean-api/src/main/java/io/ebean/config/dbplatform/DatabasePlatform.java +++ b/ebean-api/src/main/java/io/ebean/config/dbplatform/DatabasePlatform.java @@ -769,4 +769,15 @@ public class DatabasePlatform { public boolean supportsNativeJavaTime() { return supportsNativeJavaTime; } + + public String inlineSqlComment(String label) { + if (label == null) { + return ""; + } + return "/* " + label + " */ "; + } + + public String inlineSqlHint(String hint) { + return "/*+ " + hint + " */ "; + } } diff --git a/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java b/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java index 9b5afb2b0..018b5921f 100644 --- a/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java +++ b/ebean-api/src/test/java/io/ebean/config/DatabaseConfigTest.java @@ -76,6 +76,7 @@ class DatabaseConfigTest { props.setProperty("skipDataSourceCheck", "true"); props.setProperty("readOnlyDatabase", "true"); props.setProperty("lengthCheck", "ON"); + props.setProperty("includeLabelInSql", "true"); props.setProperty("queryPlan.enable", "true"); props.setProperty("queryPlan.thresholdMicros", "10000"); @@ -96,6 +97,7 @@ class DatabaseConfigTest { assertTrue(settings.isLoadModuleInfo()); assertTrue(settings.skipDataSourceCheck()); assertTrue(settings.readOnlyDatabase()); + assertTrue(settings.isIncludeLabelInSql()); assertThat(settings.getLengthCheck()).isEqualTo(LengthCheck.ON); assertTrue(settings.isIdGeneratorAutomatic()); @@ -181,6 +183,7 @@ class DatabaseConfigTest { assertEquals(10000L, config.getQueryPlanCaptureMaxTimeMillis()); assertEquals(10, config.getQueryPlanCaptureMaxCount()); assertThat(config.getLengthCheck()).isEqualTo(LengthCheck.OFF); + assertFalse(config.isIncludeLabelInSql()); config.setLoadModuleInfo(false); assertFalse(config.isAutoLoadModuleInfo()); diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml index b2881bd78..200917b00 100644 --- a/ebean-bom/pom.xml +++ b/ebean-bom/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ebean bom @@ -89,25 +89,25 @@ io.ebean ebean - 14.0.1 + 14.0.2 io.ebean ebean-api - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 io.ebean ebean-core-type - 14.0.1 + 14.0.2 @@ -125,13 +125,13 @@ io.ebean ebean-jackson-mapper - 14.0.1 + 14.0.2 io.ebean ebean-ddl-generator - 14.0.1 + 14.0.2 @@ -155,37 +155,37 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 io.ebean querybean-generator - 14.0.1 + 14.0.2 io.ebean kotlin-querybean-generator - 14.0.1 + 14.0.2 io.ebean ebean-test - 14.0.1 + 14.0.2 io.ebean ebean-redis - 14.0.1 + 14.0.2 io.ebean ebean-spring-txn - 14.0.1 + 14.0.2 @@ -193,79 +193,79 @@ io.ebean ebean-clickhouse - 14.0.1 + 14.0.2 io.ebean ebean-db2 - 14.0.1 + 14.0.2 io.ebean ebean-h2 - 14.0.1 + 14.0.2 io.ebean ebean-hana - 14.0.1 + 14.0.2 io.ebean ebean-mariadb - 14.0.1 + 14.0.2 io.ebean ebean-mysql - 14.0.1 + 14.0.2 io.ebean ebean-nuodb - 14.0.1 + 14.0.2 io.ebean ebean-oracle - 14.0.1 + 14.0.2 io.ebean ebean-postgres - 14.0.1 + 14.0.2 io.ebean ebean-postgis - 14.0.1 + 14.0.2 io.ebean ebean-postgis-types - 14.0.1 + 14.0.2 io.ebean ebean-sqlite - 14.0.1 + 14.0.2 io.ebean ebean-sqlserver - 14.0.1 + 14.0.2 diff --git a/ebean-core-type/pom.xml b/ebean-core-type/pom.xml index 7fdfb41d0..27f99a55d 100644 --- a/ebean-core-type/pom.xml +++ b/ebean-core-type/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ebean-core-type @@ -16,7 +16,7 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 diff --git a/ebean-core/pom.xml b/ebean-core/pom.xml index 7612cc9e2..893820c06 100644 --- a/ebean-core/pom.xml +++ b/ebean-core/pom.xml @@ -3,7 +3,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ebean-core @@ -22,7 +22,7 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 @@ -46,7 +46,7 @@ io.ebean ebean-core-type - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 provided @@ -62,7 +62,7 @@ io.ebean ebean-test - 14.0.1 + 14.0.2 test diff --git a/ebean-querybean/pom.xml b/ebean-querybean/pom.xml index d21e44808..62256686d 100644 --- a/ebean-querybean/pom.xml +++ b/ebean-querybean/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ebean querybean @@ -17,7 +17,7 @@ io.ebean ebean-core - 14.0.1 + 14.0.2 provided @@ -63,14 +63,14 @@ io.ebean ebean-ddl-generator - 14.0.1 + 14.0.2 test io.ebean ebean-test - 14.0.1 + 14.0.2 test @@ -84,7 +84,7 @@ io.ebean querybean-generator - 14.0.1 + 14.0.2 provided 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 41838ae7b..668ab1583 100644 --- a/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java +++ b/ebean-querybean/src/main/java/io/ebean/typequery/TQRootBean.java @@ -832,6 +832,17 @@ public abstract class TQRootBean { return root; } + /** + * Set a SQL query hint. + *

+ * This results in an inline comment that immediately follows + * after the select keyword in the form: {@code /*+ hint *\/ } + */ + public R setHint(String hint) { + query.setHint(hint); + return root; + } + /** * Set the profile location. *

diff --git a/ebean-querybean/src/test/java/org/querytest/MyInnerTest.java b/ebean-querybean/src/test/java/org/querytest/MyInnerTest.java index e196cf61b..89c40927c 100644 --- a/ebean-querybean/src/test/java/org/querytest/MyInnerTest.java +++ b/ebean-querybean/src/test/java/org/querytest/MyInnerTest.java @@ -68,9 +68,9 @@ class MyInnerTest { List sql = LoggedSql.stop(); assertThat(sql).hasSize(4); - assertThat(sql.get(0)).contains("select t0.id, t0.one, t0.id, t0.one, t0.description from my_inner t0 where t0.one = ?;"); - assertThat(sql.get(1)).contains("select t0.id, t0.one, t0.id, t0.one, t0.description from my_inner t0 where t0.description = ?;"); - assertThat(sql.get(2)).contains("select t0.id, t0.one, t0.id, t0.one, t0.description from my_inner t0 where t0.id < ? and t0.description = ?;"); - assertThat(sql.get(3)).contains("select t0.id, t0.one, t0.id, t0.one, t0.description from my_inner t0 where t0.id < ? and t0.one > ? and t0.one >= ? and t0.one < ? and t0.one <= ? and t0.id > ?;"); + assertThat(sql.get(0)).contains("select /* MyInnerTest.insert_and_find:36 */ t0.id, t0.one, t0.id, t0.one, t0.description from my_inner t0 where t0.one = ?;"); + assertThat(sql.get(1)).contains("select /* MyInnerTest.insert_and_find:43 */ t0.id, t0.one, t0.id, t0.one, t0.description from my_inner t0 where t0.description = ?;"); + assertThat(sql.get(2)).contains("select /* MyInnerTest.insert_and_find:54 */ t0.id, t0.one, t0.id, t0.one, t0.description from my_inner t0 where t0.id < ? and t0.description = ?;"); + assertThat(sql.get(3)).contains("select /* MyInnerTest.insert_and_find:65 */ t0.id, t0.one, t0.id, t0.one, t0.description from my_inner t0 where t0.id < ? and t0.one > ? and t0.one >= ? and t0.one < ? and t0.one <= ? and t0.id > ?;"); } } diff --git a/ebean-querybean/src/test/java/org/querytest/QCustomerAndOrTest.java b/ebean-querybean/src/test/java/org/querytest/QCustomerAndOrTest.java index 7862e0dcd..338741bea 100644 --- a/ebean-querybean/src/test/java/org/querytest/QCustomerAndOrTest.java +++ b/ebean-querybean/src/test/java/org/querytest/QCustomerAndOrTest.java @@ -62,6 +62,7 @@ public class QCustomerAndOrTest { @Test public void testOrWithExists() { QCustomer query = Customer.find.typed() + .setLabel("hiLabel") .alias("_cust") .or() .name.eq("Superman") @@ -72,12 +73,12 @@ public class QCustomerAndOrTest { .query() ) .endOr() - .select(QCustomer.alias().id); + .select(QCustomer.Alias.id); query.findList(); assertThat(query.getGeneratedSql()).isEqualTo( - "select _cust.id from be_customer _cust where (" + + "select /* hiLabel */ _cust.id from be_customer _cust where (" + "_cust.name = ? or exists (select 1 from be_contact contact where " + "contact.first_name = ? and contact.customer_id = _cust.id))" ); diff --git a/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java b/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java index de80d71b5..b889e231a 100644 --- a/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java +++ b/ebean-querybean/src/test/java/org/querytest/QCustomerTest.java @@ -284,7 +284,7 @@ public class QCustomerTest { .query(); q.findList(); - assertThat(q.getGeneratedSql()).isEqualTo("select t0.id, t0.name, t1.id, t1.first_name, t1.last_name from be_customer t0 left join be_contact t1 on t1.customer_id = t0.id where t1.first_name like ? escape'|' and t1.email is not null order by t0.id"); + assertThat(q.getGeneratedSql()).isEqualTo("select /* QCustomerTest.filterMany */ t0.id, t0.name, t1.id, t1.first_name, t1.last_name from be_customer t0 left join be_contact t1 on t1.customer_id = t0.id where t1.first_name like ? escape'|' and t1.email is not null order by t0.id"); } @Test @@ -296,7 +296,7 @@ public class QCustomerTest { .query(); q.findList(); - assertThat(q.getGeneratedSql()).isEqualTo("select t0.id, t0.name, t1.id, t1.first_name, t1.last_name from be_customer t0 left join be_contact t1 on t1.customer_id = t0.id where t1.first_name like ? escape'|' order by t0.id"); + assertThat(q.getGeneratedSql()).isEqualTo("select /* QCustomerTest.filterManySingle */ t0.id, t0.name, t1.id, t1.first_name, t1.last_name from be_customer t0 left join be_contact t1 on t1.customer_id = t0.id where t1.first_name like ? escape'|' order by t0.id"); } @Test diff --git a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java index 44627581d..9fd331291 100644 --- a/ebean-querybean/src/test/java/org/querytest/QOrderTest.java +++ b/ebean-querybean/src/test/java/org/querytest/QOrderTest.java @@ -22,7 +22,7 @@ import java.util.List; import static io.ebean.StdOperators.*; import static org.assertj.core.api.Assertions.assertThat; -public class QOrderTest { +class QOrderTest { private static final QCustomer cu = QCustomer.alias(); @@ -79,6 +79,19 @@ public class QOrderTest { DB.delete(customer); } + @Test + void hint() { + LoggedSql.start(); + new QCustomer() + .setHint("FirstRows") + .select(QCustomer.Alias.id, QCustomer.Alias.name) + .findList(); + + List sql = LoggedSql.stop(); + assertThat(sql).hasSize(1); + assertThat(sql.get(0)).contains("select /*+ FirstRows */ /* QOrderTest.hint */ t0.id, t0.name from be_customer t0"); + } + @Test void fetchQueryWithBatch() { LoggedSql.start(); @@ -89,12 +102,12 @@ public class QOrderTest { final List sql = LoggedSql.stop(); assertThat(sql).hasSize(2); - assertThat(sql.get(0)).contains("select t0.id, t0.name, t0.phone_number from be_customer t0"); - assertThat(sql.get(1)).contains("select t0.customer_id, t0.id, t0.first_name, t0.last_name, t0.email from be_contact t0 where"); + assertThat(sql.get(0)).contains("select /* QOrderTest.fetchQueryWithBatch */ t0.id, t0.name, t0.phone_number from be_customer t0"); + assertThat(sql.get(1)).contains("select /* QOrderTest.fetchQueryWithBatch_contacts__query */ t0.customer_id, t0.id, t0.first_name, t0.last_name, t0.email from be_contact t0 where"); } @Test - public void fetchCache() { + void fetchCache() { new QOrder() .status.eq(Order.Status.NEW) @@ -108,7 +121,7 @@ public class QOrderTest { } @Test - public void viaFetchGraph() { + void viaFetchGraph() { DB.getDefault(); LoggedSql.start(); @@ -121,11 +134,11 @@ public class QOrderTest { final List sql = LoggedSql.stop(); assertThat(sql).hasSize(1); - assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.ship_date, t0.customer_id from o_order t0 where"); + assertThat(sql.get(0)).contains("select /* QOrderTest.viaFetchGraph */ t0.id, t0.status, t0.ship_date, t0.customer_id from o_order t0 where"); } @Test - public void viaFetchGraph_withJoin() { + void viaFetchGraph_withJoin() { DB.getDefault(); LoggedSql.start(); @@ -138,11 +151,11 @@ public class QOrderTest { final List sql = LoggedSql.stop(); assertThat(sql).hasSize(1); - 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"); + assertThat(sql.get(0)).contains("select /* QOrderTest.viaFetchGraph_withJoin */ 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() { + void viaFetchGraph_withNested() { DB.getDefault(); LoggedSql.start(); @@ -154,13 +167,12 @@ public class QOrderTest { 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"); + assertThat(sql.get(0)).contains("select /* QOrderTest.viaFetchGraph_withNested */ 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(); + void viaFetchGraph_withNested_fetchQuery() { + DB.cacheManager().clearAll(); LoggedSql.start(); final Order found = new QOrder() @@ -172,17 +184,16 @@ public class QOrderTest { // 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(sql.get(0)).contains("select /* QOrderTest.viaFetchGraph_withNested_fetchQuery */ t0.id, t0.status, t0.customer_id from o_order t0 where t0.id = ?"); + assertThat(sql.get(1)).contains("select /* QOrderTest.viaFetchGraph_withNested_fetchQuery_customer__query */ 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(); + void viaFetchGraph_withNested_fetchCache() { + DB.cacheManager().clearAll(); // ensure the customer is loaded in the L2 cache new QCustomer().id.eq(customer.getId()).findOne(); @@ -201,11 +212,11 @@ public class QOrderTest { // 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 = ?"); + assertThat(sql.get(0)).contains("select /* QOrderTest.viaFetchGraph_withNested_fetchQuery */ t0.id, t0.status, t0.customer_id from o_order t0 where t0.id = ?"); } @Test - public void select_partial() { + void select_partial() { DB.getDefault(); LoggedSql.start(); @@ -218,11 +229,11 @@ public class QOrderTest { final List sql = LoggedSql.stop(); assertThat(sql).hasSize(1); - assertThat(sql.get(0)).contains("select t0.id, t0.status, t0.order_date from o_order t0"); + assertThat(sql.get(0)).contains("select /* QOrderTest.select_partial */ t0.id, t0.status, t0.order_date from o_order t0"); } @Test - public void fetch_partial() { + void fetch_partial() { DB.getDefault(); LoggedSql.start(); @@ -237,12 +248,12 @@ public class QOrderTest { final List sql = LoggedSql.stop(); assertThat(sql).hasSize(1); - assertThat(sql.get(0)).contains("select t0.id, t0.status, t1.id, t1.email, t1.name from o_order t0 join be_customer t1 on t1.id = t0.customer_id"); + assertThat(sql.get(0)).contains("select /* QOrderTest.fetch_partial */ t0.id, t0.status, t1.id, t1.email, t1.name from o_order t0 join be_customer t1 on t1.id = t0.customer_id"); } @Test - public void updateQuery() { + void updateQuery() { LoggedSql.start(); new QOrder() .status.eq(Order.Status.COMPLETE) @@ -258,7 +269,7 @@ public class QOrderTest { } @Test - public void stdExpression_iLikeConcatCoalesce() { + void stdExpression_iLikeConcatCoalesce() { QOrder o = QOrder.alias(); // LOWER(CONCAT(COALESCE(a.name, ""), ":", a.description)) LIKE LOWER(:param) @@ -273,7 +284,7 @@ public class QOrderTest { } @Test - public void stdExpression_gtCoalesce() { + void stdExpression_gtCoalesce() { QOrder o = QOrder.alias(); Query query = new QOrder() @@ -288,7 +299,7 @@ public class QOrderTest { String sql = query.getGeneratedSql(); assertThat(sql).contains(" where (coalesce(t1.version,0) > ? or t0.id < ?)"); - assertThat(sql).isEqualTo("select t0.id, t0.status from o_order t0 join be_customer t1 on t1.id = t0.customer_id where (coalesce(t1.version,0) > ? or t0.id < ?)"); + assertThat(sql).isEqualTo("select /* QOrderTest.stdExpression_gtCoalesce */ t0.id, t0.status from o_order t0 join be_customer t1 on t1.id = t0.customer_id where (coalesce(t1.version,0) > ? or t0.id < ?)"); } @Test @@ -301,7 +312,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered >= (select max(o.order_date) as foo from o_order o)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.geSqlSubQuery */ t0.id from be_customer t0 where t0.registered >= (select max(o.order_date) as foo from o_order o)"); } @Test @@ -314,7 +325,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered > (select max(o.order_date) as foo from o_order o)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.gtSqlSubQuery */ t0.id from be_customer t0 where t0.registered > (select max(o.order_date) as foo from o_order o)"); } @Test @@ -327,7 +338,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered <= (select max(o.order_date) as foo from o_order o)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.leSqlSubQuery */ t0.id from be_customer t0 where t0.registered <= (select max(o.order_date) as foo from o_order o)"); } @Test @@ -340,7 +351,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered < (select max(o.order_date) as foo from o_order o)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.ltSqlSubQuery */ t0.id from be_customer t0 where t0.registered < (select max(o.order_date) as foo from o_order o)"); } @Test @@ -353,7 +364,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered = (select max(o.order_date) as foo from o_order o)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.eqSqlSubQuery */ t0.id from be_customer t0 where t0.registered = (select max(o.order_date) as foo from o_order o)"); } @Test @@ -366,7 +377,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered <> (select max(o.order_date) as foo from o_order o)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.neSqlSubQuery */ t0.id from be_customer t0 where t0.registered <> (select max(o.order_date) as foo from o_order o)"); } @Test @@ -384,7 +395,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered >= (select max(t0.order_date) from o_order t0)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.geSubQuery */ t0.id from be_customer t0 where t0.registered >= (select max(t0.order_date) from o_order t0)"); } @Test @@ -399,7 +410,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.version > (select sum(t0.version) from o_order t0)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.gtSubQuery */ t0.id from be_customer t0 where t0.version > (select sum(t0.version) from o_order t0)"); } @Test @@ -414,7 +425,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered <= (select max(t0.order_date) from o_order t0)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.leSubQuery */ t0.id from be_customer t0 where t0.registered <= (select max(t0.order_date) from o_order t0)"); } @Test @@ -429,7 +440,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered < (select max(t0.order_date) from o_order t0)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.ltSubQuery */ t0.id from be_customer t0 where t0.registered < (select max(t0.order_date) from o_order t0)"); } @Test @@ -444,7 +455,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered = (select max(t0.order_date) from o_order t0)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.eqSubQuery */ t0.id from be_customer t0 where t0.registered = (select max(t0.order_date) from o_order t0)"); } @Test @@ -459,7 +470,7 @@ public class QOrderTest { .query(); query.findList(); - assertThat(query.getGeneratedSql()).contains("select t0.id from be_customer t0 where t0.registered <> (select max(t0.order_date) from o_order t0)"); + assertThat(query.getGeneratedSql()).contains("select /* QOrderTest.neSubQuery */ t0.id from be_customer t0 where t0.registered <> (select max(t0.order_date) from o_order t0)"); } @Test diff --git a/ebean-querybean/src/test/java/org/querytest/QueryAlsoIfTest.java b/ebean-querybean/src/test/java/org/querytest/QueryAlsoIfTest.java index 3ccc58879..a9a4dbf50 100644 --- a/ebean-querybean/src/test/java/org/querytest/QueryAlsoIfTest.java +++ b/ebean-querybean/src/test/java/org/querytest/QueryAlsoIfTest.java @@ -20,7 +20,7 @@ class QueryAlsoIfTest { .query(); q.findList(); - assertThat(q.getGeneratedSql()).isEqualTo("select t0.id, t0.name from be_customer t0 where t0.name is not null and t0.status = ?"); + assertThat(q.getGeneratedSql()).isEqualTo("select /* QueryAlsoIfTest.apply */ t0.id, t0.name from be_customer t0 where t0.name is not null and t0.status = ?"); } @Test @@ -32,6 +32,6 @@ class QueryAlsoIfTest { .query(); q.findList(); - assertThat(q.getGeneratedSql()).isEqualTo("select t0.id, t0.name from be_customer t0 where t0.name is not null"); + assertThat(q.getGeneratedSql()).isEqualTo("select /* QueryAlsoIfTest.notApply */ t0.id, t0.name from be_customer t0 where t0.name is not null"); } } diff --git a/ebean-querybean/src/test/resources/application-test.properties b/ebean-querybean/src/test/resources/application-test.properties index 9c1b1a919..5b5481d45 100644 --- a/ebean-querybean/src/test/resources/application-test.properties +++ b/ebean-querybean/src/test/resources/application-test.properties @@ -3,6 +3,7 @@ ebean.ddl.run=true ebean.ddl.initSql=init-db.sql ebean.dumpMetricsOnShutdown=true ebean.dumpMetricsOptions=sql,hash,loc +ebean.includeLabelInSql=true datasource.default=h2 diff --git a/ebean-redis/pom.xml b/ebean-redis/pom.xml index b3f711962..802b2dcb1 100644 --- a/ebean-redis/pom.xml +++ b/ebean-redis/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ebean-redis @@ -22,28 +22,28 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 provided io.ebean ebean-core - 14.0.1 + 14.0.2 provided io.ebean ebean-querybean - 14.0.1 + 14.0.2 test io.ebean ebean-test - 14.0.1 + 14.0.2 test @@ -57,7 +57,7 @@ io.ebean querybean-generator - 14.0.1 + 14.0.2 provided diff --git a/ebean-redis/src/test/java/org/integration/ClusterTest.java b/ebean-redis/src/test/java/org/integration/ClusterTest.java index 8a8142706..b5d4edb6d 100644 --- a/ebean-redis/src/test/java/org/integration/ClusterTest.java +++ b/ebean-redis/src/test/java/org/integration/ClusterTest.java @@ -1,12 +1,9 @@ package org.integration; -import io.ebean.DatabaseBuilder; -import io.ebean.redis.DuelCache; -import org.domain.Person; import io.ebean.DB; import io.ebean.Database; -import io.ebean.DatabaseFactory; -import io.ebean.config.DatabaseConfig; +import io.ebean.redis.DuelCache; +import org.domain.Person; import org.domain.query.QPerson; import org.junit.jupiter.api.Test; @@ -14,21 +11,21 @@ import javax.sql.DataSource; import static org.assertj.core.api.Assertions.assertThat; -public class ClusterTest { +class ClusterTest { private Database createOther(DataSource dataSource) { - DatabaseBuilder config = new DatabaseConfig(); - config.setDataSource(dataSource); - config.loadFromProperties(); - config.setDefaultServer(false); - config.setName("other"); - config.setDdlGenerate(false); - config.setDdlRun(false); - return DatabaseFactory.create(config); + return Database.builder() + .dataSource(dataSource) + .loadFromProperties() + .defaultDatabase(false) + .name("other") + .ddlGenerate(false) + .ddlRun(false) + .build(); } @Test - public void testBothNear() throws InterruptedException { + void testBothNear() throws InterruptedException { // ensure the default server exists first final Database db = DB.getDefault(); Database other = createOther(db.pluginApi().dataSource()); @@ -61,7 +58,7 @@ public class ClusterTest { } @Test - public void test() throws InterruptedException { + void test() throws InterruptedException { // ensure the default server exists first final Database db = DB.getDefault(); Database other = createOther(db.pluginApi().dataSource()); @@ -116,6 +113,6 @@ public class ClusterTest { } private void allowAsyncMessaging() throws InterruptedException { - Thread.sleep(100); + Thread.sleep(200); } } diff --git a/ebean-spring-txn/pom.xml b/ebean-spring-txn/pom.xml index 6cb0cda91..f02874352 100644 --- a/ebean-spring-txn/pom.xml +++ b/ebean-spring-txn/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ebean-spring-txn @@ -28,7 +28,7 @@ io.ebean ebean-core - 14.0.1 + 14.0.2 provided @@ -77,7 +77,7 @@ io.ebean ebean-test - 14.0.1 + 14.0.2 test diff --git a/ebean-test/pom.xml b/ebean-test/pom.xml index 192631849..50ec14edc 100644 --- a/ebean-test/pom.xml +++ b/ebean-test/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ebean test @@ -33,20 +33,20 @@ io.ebean ebean-platform-h2 - 14.0.1 + 14.0.2 io.ebean ebean-core - 14.0.1 + 14.0.2 provided io.ebean ebean-ddl-generator - 14.0.1 + 14.0.2 @@ -149,14 +149,14 @@ io.ebean ebean-jackson-mapper - 14.0.1 + 14.0.2 test io.ebean ebean-platform-all - 14.0.1 + 14.0.2 test diff --git a/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryFromOrmTest.java b/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryFromOrmTest.java index 6505e120d..f9f8d02cd 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryFromOrmTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/base/DtoQueryFromOrmTest.java @@ -164,8 +164,14 @@ public class DtoQueryFromOrmTest extends BaseTestCase { DtoQuery query = DB.find(Contact.class) // we must explicitly add the id property for DTO query (if we want it) - .select("id, email, " + concat("lastName", ", ", "firstName") + " as fullName").where().isNotNull("email") - .isNotNull("lastName").order().asc("lastName").asDto(ContactDto.class).setLabel("explicitId") + .setHint("SomeHint") + .select("id, email, " + concat("lastName", ", ", "firstName") + " as fullName") + .where() + .isNotNull("email") + .isNotNull("lastName") + .orderBy().asc("lastName") + .asDto(ContactDto.class) + .setLabel("explicitId") .setRelaxedMode(); List dtos = query.findList(); @@ -178,7 +184,7 @@ public class DtoQueryFromOrmTest extends BaseTestCase { } List sql = LoggedSql.stop(); - assertSql(sql.get(0)).contains("select t0.id, t0.email, " + concat("t0.last_name", ", ", "t0.first_name") + assertSql(sql.get(0)).contains("select /*+ SomeHint */ /* explicitId */ t0.id, t0.email, " + concat("t0.last_name", ", ", "t0.first_name") + " fullName from contact t0 where t0.email is not null and t0.last_name is not null order by t0.last_name"); } diff --git a/ebean-test/src/test/java/io/ebean/xtest/base/FetchGroupTest.java b/ebean-test/src/test/java/io/ebean/xtest/base/FetchGroupTest.java index 010d6460c..24708348c 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/base/FetchGroupTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/base/FetchGroupTest.java @@ -26,11 +26,12 @@ public class FetchGroupTest extends BaseTestCase { .query() .where() .ilike("name", "rob") + .setLabel("hello") .select(fetch); query.findList(); - assertThat(sqlOf(query)).contains("select t0.id, t0.name, t0.status from"); + assertThat(sqlOf(query)).contains("select /* hello */ t0.id, t0.name, t0.status from"); } diff --git a/ebean-test/src/test/java/io/ebean/xtest/config/ContainerConfigTest.java b/ebean-test/src/test/java/io/ebean/xtest/config/ContainerConfigTest.java index 6fba07abe..4f2f95e22 100644 --- a/ebean-test/src/test/java/io/ebean/xtest/config/ContainerConfigTest.java +++ b/ebean-test/src/test/java/io/ebean/xtest/config/ContainerConfigTest.java @@ -12,12 +12,20 @@ class ContainerConfigTest { @Test void loadFromProperties() { - ContainerConfig containerConfig = new ContainerConfig(); + Properties p = new Properties(); + p.setProperty("ebean.cluster.active", "true"); + p.setProperty("ebean.cluster.serviceName", "a"); + p.setProperty("ebean.cluster.namespace", "b"); + p.setProperty("ebean.cluster.podName", "c"); + p.setProperty("ebean.cluster.port", "42"); - assertThat(containerConfig.isActive()).isFalse(); - assertThat(containerConfig.getServiceName()).isNull(); - assertThat(containerConfig.getNamespace()).isNull(); - assertThat(containerConfig.getPodName()).isNull(); - assertThat(containerConfig.getPort()).isEqualTo(0); + ContainerConfig containerConfig = new ContainerConfig(); + containerConfig.loadFromProperties(p); + + assertThat(containerConfig.isActive()).isTrue(); + assertThat(containerConfig.getServiceName()).isEqualTo("a"); + assertThat(containerConfig.getNamespace()).isEqualTo("b"); + assertThat(containerConfig.getPodName()).isEqualTo("c"); + assertThat(containerConfig.getPort()).isEqualTo(42); } } diff --git a/ebean-test/src/test/java/org/tests/saveassociation/TestSaveAssociation.java b/ebean-test/src/test/java/org/tests/saveassociation/TestSaveAssociation.java index 41ae6c338..5f19f102f 100644 --- a/ebean-test/src/test/java/org/tests/saveassociation/TestSaveAssociation.java +++ b/ebean-test/src/test/java/org/tests/saveassociation/TestSaveAssociation.java @@ -6,12 +6,12 @@ import org.junit.jupiter.api.Test; import org.tests.model.basic.TSDetail; import org.tests.model.basic.TSMaster; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; -public class TestSaveAssociation extends BaseTestCase { +class TestSaveAssociation extends BaseTestCase { @Test - public void test() { + void test() { TSMaster m0 = new TSMaster(); m0.setName("master1"); @@ -26,7 +26,57 @@ public class TestSaveAssociation extends BaseTestCase { TSMaster m0Check = DB.find(TSMaster.class).fetch("details").where().idEq(m0.getId()) .findOne(); - assertEquals(2, m0Check.getDetails().size()); + assertThat(m0Check.getDetails()).hasSize(2); + DB.delete(m0); } + + @Test + void testCascadeSetParent() { + // setup + TSDetail detail = new TSDetail("master1 detail1"); + DB.save(detail); + + // act + TSMaster m0 = new TSMaster(); + m0.setName("master2"); + m0.addDetail(detail); + DB.save(m0); + + // assert + TSMaster check = DB.find(TSMaster.class).fetch("details") + .where().idEq(m0.getId()) + .findOne(); + + assertThat(check.getDetails()).hasSize(1); + assertThat(check.getDetails().get(0).getId()).isEqualTo(detail.getId()); + DB.delete(m0); + } + + @Test + void testCascadeChangeParent() { + // setup + TSDetail detail = new TSDetail("master3 detail1"); + TSMaster m0 = new TSMaster(); + m0.setName("master3"); + m0.addDetail(detail); + DB.save(m0); + + // act + TSMaster m1 = new TSMaster(); + m1.setName("master4"); + m1.addDetail(detail); + DB.save(m1); + + // assert + TSMaster check = DB.find(TSMaster.class).fetch("details") + .where().idEq(m1.getId()) + .findOne(); + + assertThat(check.getDetails()).hasSize(1); + assertThat(check.getDetails().get(0).getId()).isEqualTo(detail.getId()); + + DB.delete(m1); + DB.delete(TSMaster.class, m0.getId()); + } } diff --git a/ebean-test/src/test/resources/ebean.properties b/ebean-test/src/test/resources/ebean.properties index 6bd984585..739bc554c 100644 --- a/ebean-test/src/test/resources/ebean.properties +++ b/ebean-test/src/test/resources/ebean.properties @@ -17,6 +17,7 @@ ebean.encryptKeyManager=org.tests.basic.encrypt.BasicEncyptKeyManager #ebean.autoTune.mode=DEFAULT_ON #ebean.autoTune.profiling=true #ebean.autoTune.profilingUpdateFrequency=5 +ebean.includeLabelInSql=true ebean.ddl.generate=true ebean.ddl.run=true diff --git a/howto-deploy-to-central.md b/howto-deploy-to-central.md new file mode 100644 index 000000000..92578d30a --- /dev/null +++ b/howto-deploy-to-central.md @@ -0,0 +1,52 @@ +# Deploy to Central + +```shell +## confirm on master and building +git checkout master +mvn clean verify + +## set the appropriate version +mvs + +## run tests and package +mvn -T 4 clean package + +## deploy +mvn -T 4 deploy -pl '!composites,!platforms' -Pcentral -DskipTests -DskipStagingRepositoryClose=true -DstagingProgressTimeoutMinutes=9 + +## git commit, git tag, git push --tags +git commit -am 'Version 14.0.2' +git tag 14.0.2 +git push --tags + +## convert to javax +./jakarta-to-javax.sh + +## set javax version +mvs + +## deploy javax +mvn -T 4 clean package +mvn -T 4 deploy -pl '!composites,!platforms' -Pcentral -DskipTests -DskipStagingRepositoryClose=true -DstagingProgressTimeoutMinutes=9 + +## checkout / cleanup +git checkout . + +## goto ebean-15x branch +git checkout ebean-15x + +## update ebean-15x branch from master and resolve conflicts +git merge master +## resolve conflicts +## git commit, git push + +## set 15.x version +mvs + +## build and deploy 15.x +mvn -T 4 clean package +mvn -T 4 deploy -pl '!composites,!platforms' -Pcentral -DskipTests -DskipStagingRepositoryClose=true -DstagingProgressTimeoutMinutes=9 + +``` + + diff --git a/kotlin-querybean-generator/pom.xml b/kotlin-querybean-generator/pom.xml index 23f0e470f..4728dc347 100644 --- a/kotlin-querybean-generator/pom.xml +++ b/kotlin-querybean-generator/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 kotlin querybean generator @@ -21,7 +21,7 @@ io.ebean ebean-querybean - 14.0.1 + 14.0.2 test @@ -35,7 +35,7 @@ io.ebean ebean-core - 14.0.1 + 14.0.2 test @@ -56,14 +56,14 @@ io.ebean ebean-platform-h2 - 14.0.1 + 14.0.2 test io.ebean ebean-ddl-generator - 14.0.1 + 14.0.2 test diff --git a/platforms/all/pom.xml b/platforms/all/pom.xml index ad48fd2d3..c025d3dff 100644 --- a/platforms/all/pom.xml +++ b/platforms/all/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -15,67 +15,67 @@ io.ebean ebean-platform-h2 - 14.0.1 + 14.0.2 io.ebean ebean-platform-clickhouse - 14.0.1 + 14.0.2 io.ebean ebean-platform-db2 - 14.0.1 + 14.0.2 io.ebean ebean-platform-hana - 14.0.1 + 14.0.2 io.ebean ebean-platform-hsqldb - 14.0.1 + 14.0.2 io.ebean ebean-platform-mysql - 14.0.1 + 14.0.2 io.ebean ebean-platform-mariadb - 14.0.1 + 14.0.2 io.ebean ebean-platform-nuodb - 14.0.1 + 14.0.2 io.ebean ebean-platform-oracle - 14.0.1 + 14.0.2 io.ebean ebean-platform-postgres - 14.0.1 + 14.0.2 io.ebean ebean-platform-sqlanywhere - 14.0.1 + 14.0.2 io.ebean ebean-platform-sqlite - 14.0.1 + 14.0.2 io.ebean ebean-platform-sqlserver - 14.0.1 + 14.0.2 diff --git a/platforms/clickhouse/pom.xml b/platforms/clickhouse/pom.xml index ad911aefc..f481cc2b5 100644 --- a/platforms/clickhouse/pom.xml +++ b/platforms/clickhouse/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -15,7 +15,7 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 diff --git a/platforms/db2/pom.xml b/platforms/db2/pom.xml index 5cd12a9d3..35794cbfa 100644 --- a/platforms/db2/pom.xml +++ b/platforms/db2/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -15,7 +15,7 @@ io.ebean ebean-api - 14.0.1 + 14.0.2 diff --git a/platforms/h2/pom.xml b/platforms/h2/pom.xml index 9dccef1a2..8209910b7 100644 --- a/platforms/h2/pom.xml +++ b/platforms/h2/pom.xml @@ -4,7 +4,7 @@ ebean-parent io.ebean - 14.0.1 + 14.0.2 ../.. @@ -15,7 +15,7 @@ io.ebean ebean-api - 14.0.1 + 14.0.2