diff --git a/design/doc-query-expressions.adoc b/design/doc-query-expressions.adoc deleted file mode 100644 index 7e79333c9b..0000000000 --- a/design/doc-query-expressions.adoc +++ /dev/null @@ -1,33 +0,0 @@ -= Query - -== Expressions - -=== Paths - -=== Literals - -=== Parameters - -=== Unary expressions - -=== Arithmetic operations - -Numeric v. temporal - -=== Functions - -- Standard functions -- SqmFunctionRegistry -- Role of Dialect - -=== Concatenation operations - -=== Entity-type references - -=== CASE statements - -=== COALESCE statements - -=== NULLIF statements - -=== Sub-queries \ No newline at end of file diff --git a/design/doc-temporal.adoc b/design/doc-temporal.adoc deleted file mode 100644 index ff21ddba98..0000000000 --- a/design/doc-temporal.adoc +++ /dev/null @@ -1,10 +0,0 @@ -`OffsetDateTime` is not safe to store in database. This form does not understand "zone rules" relating to things -such as DST. An offset of +5, e.g., does not change when DST starts/ends - its just +5. - -A `ZonedDateTime` on the other hand knows the actual timezone as well as the offset for the LocalDateTime portion in -that timezone. It is much more complete picture of the actual Instant. - -The proper solution for storing "with tz" would be to always use a `ZonedDateTime`, converted from `OffsetDateTime` -if needed. In this case, I assume we need to transform a `LocalDateTime` to `ZonedDateTime`? - -^^ what about Dialects that do not support "with tz" datatype variants? Are there any anymore? diff --git a/design/working/fk.adoc b/design/fk.adoc similarity index 95% rename from design/working/fk.adoc rename to design/fk.adoc index 826cc7d1a0..c160126912 100644 --- a/design/working/fk.adoc +++ b/design/fk.adoc @@ -31,7 +31,7 @@ Assuming bi-directionality, we have 2 `Association` refs: -There is a single ForeignKeyDescriptor instance for this FK in our metamodel, with 2 Sides: +There is a single `ForeignKeyDescriptor` instance for this FK in our metamodel, with 2 Sides: ``` ForeignKeyDescriptor ( diff --git a/design/sql-ast.adoc b/design/sql-ast.adoc index 8e4d44fde8..0d869e6042 100644 --- a/design/sql-ast.adoc +++ b/design/sql-ast.adoc @@ -30,10 +30,11 @@ The actual tree nodes are defined in the `org.hibernate.sql.ast.tree` package. == Building SQL AST -There are 2 main producers of SQL AST atm: +There are 3 main producers of SQL AST: -* SQM translation - see `org.hibernate.query.sqm.sql` -* metamodel-based loading - see `org.hibernate.loader.internal.MetamodelSelectBuilderProcess` +SQM:: Translation of HQL and criteria queries. See `org.hibernate.query.sqm.sql` +Loading:: SQL generated for persistence-context events to load entities and collections. This includes `Session#find`, `Session#get`, `Session#lock`, ... See `org.hibernate.loader.internal.MetamodelSelectBuilderProcess` +Mutations:: SQL generated for persistence-context flush events to write entity and collection state to the database. See `org.hibernate.persister.entity.mutation` and `org.hibernate.persister.collection.mutation` == Translating SQL AST diff --git a/design/working/6.0-posts.adoc b/design/working/6.0-posts.adoc index d1d1ae52d7..690f6780b8 100644 --- a/design/working/6.0-posts.adoc +++ b/design/working/6.0-posts.adoc @@ -37,7 +37,7 @@ from the removal of deprecated stuff. There are a few one-off changes that brea source compatibility; these are covered in the link:{migration-guide-url}[migration guide]. One specific change to note is that many of these contracts have been better defined with type -parameters. Theses were inconsistently and sometimes poorly defined in previous versions. +parameters. Theses were inconsistently (and sometimes poorly) defined in previous versions. Quite a few SPI contracts have changed to support many of the topics discussed here as well as in the link:{migration-guide-url}[migration guide]. Many will also be the subject of the mentioned @@ -267,4 +267,4 @@ For additional details, see: - the link:{migration-guide-url}[Migration Guide] - the https://hibernate.org/orm/releases/6.0/[release page]. -To get in touch, use the usual channels as discussed on the https://hibernate.org/community/[website]. \ No newline at end of file +To get in touch, use the usual channels as discussed on the https://hibernate.org/community/[website]. diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/CollectionHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/CollectionHelper.java index 00a13f9dbd..2fc6faca75 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/CollectionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/CollectionHelper.java @@ -7,6 +7,7 @@ package org.hibernate.internal.util.collections; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -275,6 +276,10 @@ public final class CollectionHelper { return objects == null || objects.length == 0; } + public static boolean isNotEmpty(Object[] objects) { + return objects != null && objects.length > 0; + } + public static List listOf(T value1) { final List list = new ArrayList<>( 1 ); list.add( value1 ); @@ -418,6 +423,17 @@ public final class CollectionHelper { return result; } + public static Map toSettingsMap(Object... pairs) { + assert pairs.length % 2 == 0; + if ( pairs.length == 2 ) { + return Collections.singletonMap( (String) pairs[0], pairs[1] ); + } + + final Map result = new HashMap<>(); + applyToMap( result, pairs ); + return result; + } + @SuppressWarnings({ "unchecked", "rawtypes" }) private static void applyToMap(Map map, Object... pairs) { assert pairs.length % 2 == 0; @@ -472,4 +488,12 @@ public final class CollectionHelper { public static int size(List values) { return values == null ? 0 : values.size(); } + + public static Set toSet(X... values) { + final HashSet result = new HashSet<>(); + if ( isNotEmpty( values ) ) { + result.addAll( Arrays.asList( values ) ); + } + return result; + } }