Skip to content

Commit 98e9c46

Browse files
committed
Merge branch 'o-main' into main-perf
2 parents 07019d8 + 537602b commit 98e9c46

File tree

69 files changed

+2050
-760
lines changed

Some content is hidden

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

69 files changed

+2050
-760
lines changed

documentation/src/main/asciidoc/userguide/chapters/jdbc/Database_Access.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ The value for `hibernate.connection.isolation` can be specified in one of 3 form
189189
* the integer value accepted at the JDBC level.
190190
* the name of the `java.sql.Connection` constant field representing the isolation you would like to use.
191191
For example, `TRANSACTION_REPEATABLE_READ` for https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html#TRANSACTION_REPEATABLE_READ[`java.sql.Connection#TRANSACTION_REPEATABLE_READ`].
192-
Not that this is only supported for JDBC standard isolation levels, not for isolation levels specific to a particular JDBC driver.
192+
Note that this is only supported for JDBC standard isolation levels, not for isolation levels specific to a particular JDBC driver.
193193
* a short-name version of the java.sql.Connection constant field without the `TRANSACTION_` prefix. For example, `REPEATABLE_READ` for https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html#TRANSACTION_REPEATABLE_READ[`java.sql.Connection#TRANSACTION_REPEATABLE_READ`].
194194
Again, this is only supported for JDBC standard isolation levels, not for isolation levels specific to a particular JDBC driver.
195195

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Keep all these properties in sync unless you know what you are doing!
22
# We set '-Dlog4j2.disableJmx=true' to prevent classloader leaks triggered by the logger.
33
# (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
4+
org.gradle.jvmargs=-Dlog4j2.disableJmx -Xmx3g -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 -Xmx3g -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 -Xmx3g -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 -Xmx3g -XX:MaxMetaspaceSize=384m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8
88

99
org.gradle.parallel=true
1010

gradle/libraries.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
77

8-
configurations.all {
8+
configurations.configureEach {
99
resolutionStrategy.eachDependency { details ->
1010
//Force the "byte buddy agent" version to match the Byte Buddy version
1111
// we use, as Mockito might pull in a mismatched version transitively

gradle/wrapper/gradle-wrapper.jar

2.04 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
4+
networkTimeout=10000
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

gradlew

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,10 +80,10 @@ do
8080
esac
8181
done
8282

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
83+
# This is normally unused
84+
# shellcheck disable=SC2034
8685
APP_BASE_NAME=${0##*/}
86+
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
8787

8888
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
8989
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@@ -143,12 +143,16 @@ fi
143143
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144144
case $MAX_FD in #(
145145
max*)
146+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147+
# shellcheck disable=SC3045
146148
MAX_FD=$( ulimit -H -n ) ||
147149
warn "Could not query maximum file descriptor limit"
148150
esac
149151
case $MAX_FD in #(
150152
'' | soft) :;; #(
151153
*)
154+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155+
# shellcheck disable=SC3045
152156
ulimit -n "$MAX_FD" ||
153157
warn "Could not set maximum file descriptor limit to $MAX_FD"
154158
esac
@@ -205,6 +209,12 @@ set -- \
205209
org.gradle.wrapper.GradleWrapperMain \
206210
"$@"
207211

212+
# Stop when "xargs" is not available.
213+
if ! command -v xargs >/dev/null 2>&1
214+
then
215+
die "xargs is not available"
216+
fi
217+
208218
# Use "xargs" to parse quoted args.
209219
#
210220
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

gradlew.bat

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
29+
@rem This is normally unused
2930
set APP_BASE_NAME=%~n0
3031
set APP_HOME=%DIRNAME%
3132

@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4041

4142
set JAVA_EXE=java.exe
4243
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
44+
if %ERRORLEVEL% equ 0 goto execute
4445

4546
echo.
4647
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7576

7677
:end
7778
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
if %ERRORLEVEL% equ 0 goto mainEnd
7980

8081
:fail
8182
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8283
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
84+
set EXIT_CODE=%ERRORLEVEL%
85+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
86+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87+
exit /b %EXIT_CODE%
8588

8689
:mainEnd
8790
if "%OS%"=="Windows_NT" endlocal

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package org.hibernate.community.dialect;
88

99
import org.hibernate.dialect.DialectDelegateWrapper;
10-
import org.hibernate.dialect.MySQLDialect;
1110
import org.hibernate.dialect.MySQLSqlAstTranslator;
1211
import org.hibernate.engine.spi.SessionFactoryImplementor;
1312
import org.hibernate.query.sqm.ComparisonOperator;
@@ -245,8 +244,8 @@ protected String getFromDualForSelectOnly() {
245244
}
246245

247246
@Override
248-
public MySQLDialect getDialect() {
249-
return (MySQLDialect) DialectDelegateWrapper.extractRealDialect( super.getDialect() );
247+
public MySQLLegacyDialect getDialect() {
248+
return (MySQLLegacyDialect) DialectDelegateWrapper.extractRealDialect( super.getDialect() );
250249
}
251250

252251
@Override

hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@
201201

202202
import static java.lang.Math.ceil;
203203
import static java.lang.Math.log;
204-
import static java.util.Arrays.sort;
205204
import static org.hibernate.cfg.AvailableSettings.NON_CONTEXTUAL_LOB_CREATION;
206205
import static org.hibernate.cfg.AvailableSettings.STATEMENT_BATCH_SIZE;
207206
import static org.hibernate.cfg.AvailableSettings.USE_GET_GENERATED_KEYS;
@@ -761,19 +760,15 @@ public String getEnumTypeDeclaration(String name, String[] values) {
761760
}
762761

763762
public String getEnumTypeDeclaration(Class<? extends Enum<?>> enumType) {
764-
String[] values = getEnumeratedValues( enumType );
765-
sort( values ); //sort alphabetically, to guarantee alphabetical ordering in queries with 'order by'
766-
return getEnumTypeDeclaration( enumType.getSimpleName(), values );
763+
return getEnumTypeDeclaration( enumType.getSimpleName(), getEnumeratedValues( enumType ) );
767764
}
768765

769766
public String[] getCreateEnumTypeCommand(String name, String[] values) {
770767
return EMPTY_STRING_ARRAY;
771768
}
772769

773770
public String[] getCreateEnumTypeCommand(Class<? extends Enum<?>> enumType) {
774-
String[] values = getEnumeratedValues( enumType );
775-
sort( values ); //sort alphabetically, to guarantee alphabetical ordering in queries with 'order by'
776-
return getCreateEnumTypeCommand( enumType.getSimpleName(), values );
771+
return getCreateEnumTypeCommand( enumType.getSimpleName(), getEnumeratedValues( enumType ) );
777772
}
778773

779774
public String[] getDropEnumTypeCommand(String name) {

hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryDelegatingImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public boolean isOpen() {
350350
}
351351

352352
@Override @Deprecated
353-
public <T> BindableType<? extends T> resolveParameterBindType(T bindValue) {
353+
public <T> BindableType<? super T> resolveParameterBindType(T bindValue) {
354354
return delegate.resolveParameterBindType( bindValue );
355355
}
356356

hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ interface DeserializationResolver<T extends SessionFactoryImplementor> extends S
217217
* @deprecated Use {@link #getMappingMetamodel()}.{@link MappingMetamodelImplementor#resolveParameterBindType(Object)}
218218
*/
219219
@Override @Deprecated(since = "6.2", forRemoval = true)
220-
<T> BindableType<? extends T> resolveParameterBindType(T bindValue);
220+
<T> BindableType<? super T> resolveParameterBindType(T bindValue);
221221

222222
/**
223223
* @deprecated Use {@link #getMappingMetamodel()}.{@link MappingMetamodelImplementor#resolveParameterBindType(Class)}

hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private boolean handleIdType(EntityPersister persister, LoadEvent event, LoadTyp
146146
return false;
147147
}
148148
else {
149-
return true;
149+
return !idClass.isInstance( event.getEntityId() );
150150
}
151151
}
152152
else {

hibernate-core/src/main/java/org/hibernate/id/enhanced/HiLoOptimizer.java

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import java.io.Serializable;
1010
import java.util.Map;
1111
import java.util.concurrent.ConcurrentHashMap;
12+
import java.util.concurrent.locks.Lock;
13+
import java.util.concurrent.locks.ReentrantLock;
1214

1315
import org.hibernate.HibernateException;
1416
import org.hibernate.id.IntegralDataTypeHolder;
@@ -80,29 +82,39 @@ public HiLoOptimizer(Class<?> returnClass, int incrementSize) {
8082
}
8183

8284
@Override
83-
public synchronized Serializable generate(AccessCallback callback) {
84-
final GenerationState generationState = locateGenerationState( callback.getTenantIdentifier() );
85-
86-
if ( generationState.lastSourceValue == null ) {
87-
// first call, so initialize ourselves. we need to read the database
88-
// value and set up the 'bucket' boundaries
89-
generationState.lastSourceValue = callback.getNextValue();
90-
while ( generationState.lastSourceValue.lt( 1 ) ) {
85+
public Serializable generate(AccessCallback callback) {
86+
lock.lock();
87+
try {
88+
final GenerationState generationState = locateGenerationState( callback.getTenantIdentifier() );
89+
90+
if ( generationState.lastSourceValue == null ) {
91+
// first call, so initialize ourselves. we need to read the database
92+
// value and set up the 'bucket' boundaries
9193
generationState.lastSourceValue = callback.getNextValue();
94+
while ( generationState.lastSourceValue.lt( 1 ) ) {
95+
generationState.lastSourceValue = callback.getNextValue();
96+
}
97+
// upperLimit defines the upper end of the bucket values
98+
generationState.upperLimit = generationState.lastSourceValue.copy().multiplyBy( incrementSize ).increment();
99+
// initialize value to the lower end of the bucket
100+
generationState.value = generationState.upperLimit.copy().subtract( incrementSize );
101+
}
102+
else if ( ! generationState.upperLimit.gt( generationState.value ) ) {
103+
generationState.lastSourceValue = callback.getNextValue();
104+
generationState.upperLimit = generationState.lastSourceValue.copy().multiplyBy( incrementSize ).increment();
105+
generationState.value = generationState.upperLimit.copy().subtract( incrementSize );
92106
}
93-
// upperLimit defines the upper end of the bucket values
94-
generationState.upperLimit = generationState.lastSourceValue.copy().multiplyBy( incrementSize ).increment();
95-
// initialize value to the lower end of the bucket
96-
generationState.value = generationState.upperLimit.copy().subtract( incrementSize );
107+
return generationState.value.makeValueThenIncrement();
97108
}
98-
else if ( ! generationState.upperLimit.gt( generationState.value ) ) {
99-
generationState.lastSourceValue = callback.getNextValue();
100-
generationState.upperLimit = generationState.lastSourceValue.copy().multiplyBy( incrementSize ).increment();
101-
generationState.value = generationState.upperLimit.copy().subtract( incrementSize );
109+
finally {
110+
lock.unlock();
102111
}
103-
return generationState.value.makeValueThenIncrement();
104112
}
105113

114+
/**
115+
* Use a lock instead of the monitor lock to avoid pinning when using virtual threads.
116+
*/
117+
private final Lock lock = new ReentrantLock();
106118
private GenerationState noTenantState;
107119
private Map<String,GenerationState> tenantSpecificState;
108120

@@ -139,8 +151,14 @@ private GenerationState noTenantGenerationState() {
139151
}
140152

141153
@Override
142-
public synchronized IntegralDataTypeHolder getLastSourceValue() {
143-
return noTenantGenerationState().lastSourceValue;
154+
public IntegralDataTypeHolder getLastSourceValue() {
155+
lock.lock();
156+
try {
157+
return noTenantGenerationState().lastSourceValue;
158+
}
159+
finally {
160+
lock.unlock();
161+
}
144162
}
145163

146164
@Override
@@ -155,8 +173,14 @@ public boolean applyIncrementSizeToSourceValues() {
155173
*
156174
* @return Value for property 'lastValue'.
157175
*/
158-
public synchronized IntegralDataTypeHolder getLastValue() {
159-
return noTenantGenerationState().value.copy().decrement();
176+
public IntegralDataTypeHolder getLastValue() {
177+
lock.lock();
178+
try {
179+
return noTenantGenerationState().value.copy().decrement();
180+
}
181+
finally {
182+
lock.unlock();
183+
}
160184
}
161185

162186
/**
@@ -166,7 +190,13 @@ public synchronized IntegralDataTypeHolder getLastValue() {
166190
*
167191
* @return Value for property 'upperLimit'.
168192
*/
169-
public synchronized IntegralDataTypeHolder getHiValue() {
170-
return noTenantGenerationState().upperLimit;
193+
public IntegralDataTypeHolder getHiValue() {
194+
lock.lock();
195+
try {
196+
return noTenantGenerationState().upperLimit;
197+
}
198+
finally {
199+
lock.unlock();
200+
}
171201
}
172202
}

0 commit comments

Comments
 (0)