Skip to content

Commit 1c612be

Browse files
committed
Merge branch 'o-main' into main-perf
2 parents da5ec20 + d415b5f commit 1c612be

File tree

185 files changed

+4439
-2022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+4439
-2022
lines changed

docker_db.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
724724
SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';
725725
ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 600;
726726
ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 600;
727+
SET CLUSTER SETTING sql.defaults.serial_normalization=sql_sequence;
727728
728729
quit
729730
EOF
@@ -764,6 +765,7 @@ SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
764765
SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';
765766
ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 600;
766767
ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 600;
768+
SET CLUSTER SETTING sql.defaults.serial_normalization=sql_sequence;
767769
768770
quit
769771
EOF
@@ -809,6 +811,7 @@ SET CLUSTER SETTING timeseries.storage.resolution_30m.ttl = '0s';
809811
ALTER RANGE default CONFIGURE ZONE USING \"gc.ttlseconds\" = 10;
810812
ALTER DATABASE system CONFIGURE ZONE USING \"gc.ttlseconds\" = 10;
811813
ALTER DATABASE defaultdb CONFIGURE ZONE USING \"gc.ttlseconds\" = 10;
814+
SET CLUSTER SETTING sql.defaults.serial_normalization=sql_sequence;
812815
quit
813816
EOF
814817
"

documentation/src/main/asciidoc/introduction/Hibernate_Introduction.adoc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,11 @@ include::Preface.adoc[]
1717
:numbered:
1818

1919
include::Introduction.adoc[]
20-
2120
include::Configuration.adoc[]
22-
2321
include::Entities.adoc[]
24-
2522
include::Mapping.adoc[]
26-
2723
include::Interacting.adoc[]
28-
2924
include::Generator.adoc[]
30-
31-
// include::../userguide/chapters/query/hql/Hibernate_Query_Language.adoc[]
32-
3325
include::Tuning.adoc[]
34-
3526
include::Advanced.adoc[]
36-
3727
include::Credits.adoc[]

documentation/src/main/asciidoc/introduction/Interacting.adoc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -705,14 +705,11 @@ query.select(book).where(where)
705705

706706
Here, as before, the classes `Book_` and `Author_` are generated by Hibernate's <<metamodel-generator,JPA Metamodel Generator>>.
707707

708-
[CAUTION]
708+
[NOTE]
709709
// .Injection attacks and criteria queries
710710
====
711711
Notice that we did not bother treating `titlePattern` and `namePattern` as parameters.
712-
That's safe because, _by default_, Hibernate automatically and transparently handles any literal string passed to the `CriteriaBuilder` as a JDBC parameter.
713-
714-
But this behavior is controlled by the configuration setting `hibernate.criteria.value_handling_mode`.
715-
If you change the default behavior, and set the property to `INLINE` instead of `BIND`, you _must_ pass user-input via a JPA `ParameterExpression`.
712+
That's safe because, by default, Hibernate automatically and transparently treats strings passed to the `CriteriaBuilder` as JDBC parameters.
716713
====
717714

718715
Execution of a criteria query works almost exactly like execution of HQL.
@@ -1214,4 +1211,5 @@ In this section we'll quickly sketch some general strategies for avoiding "quagm
12141211
Instead, _understand_ what you're doing; study the Javadoc of the APIs you're using; read the JPA specification; follow the advice we give in this document; go direct to the Hibernate team on Zulip.
12151212
(Sure, we can be a bit cantankerous at times, but we _do_ always want you to be successful.)
12161213
- Always consider other options.
1217-
You don't have to use Hibernate for _everything_.
1214+
You don't have to use Hibernate for _everything_.
1215+

documentation/src/main/asciidoc/introduction/Tuning.adoc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,12 @@ Clever, huh?
220220
Both batch fetching and subselect fetching are disabled by default, but we may enable one or the other globally using properties.
221221

222222
.Configuration settings to enable batch and subselect fetching
223-
[%breakable,cols="35,~, 20"]
223+
[%breakable,cols="32,~,28"]
224224
|===
225-
| Configuration property name | Property value | Alternative
225+
| Configuration property name | Property value | Alternatives
226226

227-
| `hibernate.default_batch_fetch_size` | A sensible batch size `>1` to enable batch fetching | `@BatchSize`, `setFetchBatchSize()`
228-
| `hibernate.use_subselect_fetch` | `true` to enable subselect fetching | `@Fetch(SUBSELECT)`
227+
| `hibernate.default_batch_fetch_size` | A sensible batch size `>1` to enable batch fetching | `@BatchSize()`, `setFetchBatchSize()`
228+
| `hibernate.use_subselect_fetch` | `true` to enable subselect fetching | `@Fetch(SUBSELECT)`, `setSubselectFetchingEnabled()`
229229
|===
230230

231231
Alternatively, we can enable one or the other in a given session:
@@ -1010,4 +1010,11 @@ The comment text may be customized:
10101010

10111011
Finally, many systems which require high scalability now make use of reactive programming and reactive streams.
10121012
{hr}[Hibernate Reactive] brings O/R mapping to the world of reactive programming.
1013-
You can learn much more about Hibernate Reactive from its {hr-guide}[Reference Documentation].
1013+
You can learn much more about Hibernate Reactive from its {hr-guide}[Reference Documentation].
1014+
1015+
[TIP]
1016+
====
1017+
Hibernate Reactive may be used alongside vanilla Hibernate in the same program, and can reuse the same entity classes.
1018+
This means you can use the reactive programming model exactly where you need it—perhaps only in one or two places in your system.
1019+
You don't need to rewrite your whole program using reactive streams.
1020+
====

documentation/src/main/asciidoc/querylanguage/Hibernate_Query_Language.adoc

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,13 @@
1919
:toc:
2020
:toclevels: 3
2121

22-
<<<
23-
2422
include::Preface.adoc[]
2523

26-
<<<
27-
2824
:numbered:
2925

3026
include::Concepts.adoc[]
31-
32-
<<<
33-
3427
include::Expressions.adoc[]
35-
36-
<<<
37-
3828
include::From.adoc[]
39-
40-
<<<
41-
4229
include::Relational.adoc[]
43-
44-
<<<
45-
4630
include::Credits.adoc[]
4731

gradle.properties

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Keep all these properties in sync unless you know what you are doing!
2-
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
3-
toolchain.compiler.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
4-
toolchain.javadoc.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
5-
toolchain.launcher.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
2+
# We set '-Dlog4j2.disableJmx=true' to prevent classloader leaks triggered by the logger.
3+
# (Some of these settings need to be repeated in the test.jvmArgs blocks of each module)
4+
org.gradle.jvmargs=-Dlog4j2.disableJmx -Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
5+
toolchain.compiler.jvmargs=-Dlog4j2.disableJmx=true -Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
6+
toolchain.javadoc.jvmargs=-Dlog4j2.disableJmx=true -Xmx2g -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
7+
toolchain.launcher.jvmargs=-Dlog4j2.disableJmx=true -Xmx2g -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
68

79
org.gradle.parallel=true
810

gradle/databases.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ext {
1818
'jdbc.driver': 'org.h2.Driver',
1919
'jdbc.user' : 'sa',
2020
'jdbc.pass' : '',
21-
'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000',
21+
'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE',
2222
'connection.init_sql' : '',
2323
'hibernate.dialect.native_param_markers' : 'true'
2424
],

gradle/java-module.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ test {
376376
// Used in the Travis build so that Travis doesn't end up panicking because there's no output for a long time.
377377
testLogging {
378378
events "passed", "skipped", "failed"
379+
exceptionFormat = 'full'
379380
}
380381
}
381382
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/DB2LegacySqlAstTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ protected void renderComparison(Expression lhs, ComparisonOperator operator, Exp
420420
break;
421421
}
422422
}
423-
renderComparisonEmulateDecode( lhs, operator, rhs );
423+
renderComparisonEmulateDecode( lhs, operator, rhs, SqlAstNodeRenderingMode.NO_UNTYPED );
424424
}
425425
}
426426

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ public boolean supportsStandardArrays() {
200200
return getVersion().isSameOrAfter( 2 );
201201
}
202202

203+
@Override
204+
public boolean useArrayForMultiValuedParameters() {
205+
// Performance is worse than the in-predicate version
206+
return false;
207+
}
208+
203209
@Override
204210
protected String columnType(int sqlTypeCode) {
205211
switch ( sqlTypeCode ) {

hibernate-core/hibernate-core.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ tasks.withType( Test.class ).each { test ->
245245
test.jvmArgs( ['--add-opens', 'java.base/java.security=ALL-UNNAMED'] )
246246
test.jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
247247

248+
//Avoid Log4J2 classloader leaks:
249+
test.jvmArgs( ['-Dlog4j2.disableJmx=true'] )
250+
248251
test.beforeTest { descriptor ->
249252
//println "Starting test: " + descriptor
250253
}

hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ queryExpression
152152
orderedQuery
153153
: query queryOrder? # QuerySpecExpression
154154
| LEFT_PAREN queryExpression RIGHT_PAREN queryOrder? # NestedQueryExpression
155+
| queryOrder # QueryOrderExpression
155156
;
156157

157158
/**
@@ -180,6 +181,7 @@ query
180181
// TODO: add with clause
181182
: selectClause fromClause? whereClause? (groupByClause havingClause?)?
182183
| fromClause whereClause? (groupByClause havingClause?)? selectClause?
184+
| whereClause
183185
;
184186

185187

hibernate-core/src/main/java/org/hibernate/InstantiationException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class InstantiationException extends HibernateException {
1515
private final Class<?> clazz;
1616

1717
/**
18-
* Constructs a {@code InstantiationException}.
18+
* Constructs an {@code InstantiationException}.
1919
*
2020
* @param message A message explaining the exception condition
2121
* @param clazz The Class we are attempting to instantiate

hibernate-core/src/main/java/org/hibernate/Session.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ public interface Session extends SharedSessionContract, EntityManager {
183183
void setFlushMode(FlushModeType flushMode);
184184

185185
/**
186-
* Set the current {@link FlushMode flush mode} for this session.
186+
* Set the current {@linkplain FlushMode flush mode} for this session.
187187
* <p>
188188
* <em>Flushing</em> is the process of synchronizing the underlying persistent
189189
* store with persistable state held in memory. The current flush mode determines
190190
* when the session is automatically flushed.
191191
* <p>
192-
* The {@link FlushMode#AUTO default flush mode} is sometimes unnecessarily
192+
* The {@linkplain FlushMode#AUTO default flush mode} is sometimes unnecessarily
193193
* aggressive. For a logically "read only" session, it's reasonable to set the
194194
* session's flush mode to {@link FlushMode#MANUAL} at the start of the session
195195
* in order to avoid some unnecessary work.
@@ -201,22 +201,22 @@ public interface Session extends SharedSessionContract, EntityManager {
201201
void setHibernateFlushMode(FlushMode flushMode);
202202

203203
/**
204-
* Get the current {@link FlushModeType JPA flush mode} for this session.
204+
* Get the current {@linkplain FlushModeType JPA flush mode} for this session.
205205
*
206206
* @return the {@link FlushModeType} currently in effect
207207
*/
208208
@Override
209209
FlushModeType getFlushMode();
210210

211211
/**
212-
* Get the current {@link FlushMode flush mode} for this session.
212+
* Get the current {@linkplain FlushMode flush mode} for this session.
213213
*
214214
* @return the {@link FlushMode} currently in effect
215215
*/
216216
FlushMode getHibernateFlushMode();
217217

218218
/**
219-
* Set the current {@link CacheMode cache mode} for this session.
219+
* Set the current {@linkplain CacheMode cache mode} for this session.
220220
* <p>
221221
* The cache mode determines the manner in which this session can interact with
222222
* the second level cache.
@@ -226,7 +226,7 @@ public interface Session extends SharedSessionContract, EntityManager {
226226
void setCacheMode(CacheMode cacheMode);
227227

228228
/**
229-
* Get the current {@link CacheMode cache mode} for this session.
229+
* Get the current {@linkplain CacheMode cache mode} for this session.
230230
*
231231
* @return the current cache mode
232232
*/

hibernate-core/src/main/java/org/hibernate/SessionFactory.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ default void inSession(Consumer<Session> action) {
220220

221221
/**
222222
* Open a {@link StatelessSession} and use it to perform an action.
223+
*
224+
* @since 6.3
223225
*/
224226
default void inStatelessSession(Consumer<StatelessSession> action) {
225227
try ( StatelessSession session = openStatelessSession() ) {
@@ -238,6 +240,8 @@ default void inTransaction(Consumer<Session> action) {
238240
/**
239241
* Open a {@link StatelessSession} and use it to perform an action
240242
* within the bounds of a transaction.
243+
*
244+
* @since 6.3
241245
*/
242246
default void inStatelessTransaction(Consumer<StatelessSession> action) {
243247
inStatelessSession( session -> manageTransaction( session, session.beginTransaction(), action ) );
@@ -254,6 +258,8 @@ default <R> R fromSession(Function<Session,R> action) {
254258

255259
/**
256260
* Open a {@link StatelessSession} and use it to obtain a value.
261+
*
262+
* @since 6.3
257263
*/
258264
default <R> R fromStatelessSession(Function<StatelessSession,R> action) {
259265
try ( StatelessSession session = openStatelessSession() ) {
@@ -272,6 +278,8 @@ default <R> R fromTransaction(Function<Session,R> action) {
272278
/**
273279
* Open a {@link StatelessSession} and use it to obtain a value
274280
* within the bounds of a transaction.
281+
*
282+
* @since 6.3
275283
*/
276284
default <R> R fromStatelessTransaction(Function<StatelessSession,R> action) {
277285
return fromStatelessSession( session -> manageTransaction( session, session.beginTransaction(), action ) );

hibernate-core/src/main/java/org/hibernate/annotations/processing/Find.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@
113113
* {@linkplain jakarta.persistence.criteria.CriteriaBuilder criteria
114114
* query}.
115115
* </ul>
116+
* <p>
117+
* As an exception, the method may have at most one parameter of
118+
* type {@code EntityManager}, {@code Session},
119+
* {@code StatelessSession}, or {@code Mutiny.Session}.
116120
*
117121
* @see HQL
118122
* @see SQL

hibernate-core/src/main/java/org/hibernate/annotations/processing/HQL.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
* Alternatively, the type to which the annotated method belongs may
5050
* also declare an abstract method with no parameters which returns
5151
* one of the types {@link jakarta.persistence.EntityManager},
52-
* {@link org.hibernate.StatelessSession},
53-
* or {@link org.hibernate.Session}, for example:
52+
* {@link org.hibernate.Session},
53+
* {@link org.hibernate.StatelessSession}, or {@code Mutiny.Session},
54+
* for example:
5455
* <pre>
5556
* EntityManager entityManager();
5657
* </pre>
@@ -74,7 +75,8 @@
7475
* <p>
7576
* This is reminiscent of traditional DAO-style repositories.
7677
* <p>
77-
* The return type of an annotated method must be:
78+
* For a {@code select} query, the return type of an annotated method
79+
* must be:
7880
* <ul>
7981
* <li>an entity type,
8082
* <li>{@link java.util.List},
@@ -84,6 +86,10 @@
8486
* <li>{@link jakarta.persistence.TypedQuery}.
8587
* </ul>
8688
* <p>
89+
* For an {@code insert}, {@code update}, or {@code delete} query,
90+
* the return type of the annotated method must be {@code int} or
91+
* {@code void}.
92+
* <p>
8793
* The method parameters must match the parameters of the HQL query,
8894
* either by name or by position:
8995
* <ul>
@@ -95,6 +101,8 @@
95101
* <p>
96102
* As an exception, the method may have:
97103
* <ul>
104+
* <li>a parameter of type {@code EntityManager}, {@code Session},
105+
* {@code StatelessSession}, or {@code Mutiny.Session},
98106
* <li>a parameter with type {@code Page}, and/or
99107
* <li>a parameter with type {@code Order<? super E>},
100108
* {@code List<Order<? super E>>}, or {@code Order<? super E>...}

hibernate-core/src/main/java/org/hibernate/annotations/processing/SQL.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
* Alternatively, the type to which the annotated method belongs may
5050
* also declare an abstract method with no parameters which returns
5151
* one of the types {@link jakarta.persistence.EntityManager},
52-
* {@link org.hibernate.StatelessSession},
53-
* or {@link org.hibernate.Session}, for example:
52+
* {@link org.hibernate.Session},
53+
* {@link org.hibernate.StatelessSession}, or {@code Mutiny.Session},
54+
* for example:
5455
* <pre>
5556
* EntityManager entityManager();
5657
* </pre>
@@ -91,6 +92,10 @@
9192
* <li>a named query parameter of form {@code :name} is matched to
9293
* the method parameter {@code name}.
9394
* </ul>
95+
* <p>
96+
* As an exception, the method may have at most one parameter of
97+
* type {@code EntityManager}, {@code Session},
98+
* {@code StatelessSession}, or {@code Mutiny.Session}.
9499
*
95100
* @see HQL
96101
* @see Find

0 commit comments

Comments
 (0)