Skip to content

Commit b860887

Browse files
committed
Merge remote-tracking branch 'upstream/main' into main-perf
2 parents 49e946a + 8aa1647 commit b860887

File tree

182 files changed

+985
-681
lines changed

Some content is hidden

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

182 files changed

+985
-681
lines changed

hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/SQLServer2005DialectTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* Unit test of the behavior of the SQLServerDialect utility methods
2727
*
2828
* @author Valotasion Yoryos
29-
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
29+
* @author Lukasz Antoniak
3030
* @author Chris Cranford
3131
*/
3232
public class SQLServer2005DialectTestCase extends BaseUnitTestCase {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
* An easy way to be sure that session and transaction management is being done correctly
119119
* is to {@linkplain SessionFactory#inTransaction(Consumer) let the factory do it}:
120120
* <pre>
121-
* sessionFactory.inTransaction(session -> {
121+
* sessionFactory.inTransaction(session -&gt; {
122122
* //do the work
123123
* ...
124124
* });
@@ -127,7 +127,7 @@
127127
* A session may be used to {@linkplain #doWork(Work) execute JDBC work} using its JDBC
128128
* connection and transaction:
129129
* <pre>
130-
* session.doWork(connection -> {
130+
* session.doWork(connection -&gt; {
131131
* try ( PreparedStatement ps = connection.prepareStatement( " ... " ) ) {
132132
* ps.execute();
133133
* }

hibernate-core/src/main/java/org/hibernate/annotations/CompositeTypeRegistration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
@Retention( RUNTIME )
3434
@Repeatable( CompositeTypeRegistrations.class )
3535
public @interface CompositeTypeRegistration {
36+
/**
37+
* The embeddable type described by the {@link #userType}.
38+
*/
3639
Class<?> embeddableClass();
40+
41+
/**
42+
* The {@link CompositeUserType}.
43+
*/
3744
Class<? extends CompositeUserType<?>> userType();
3845
}

hibernate-core/src/main/java/org/hibernate/annotations/JavaTypeRegistration.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@
1919
import static java.lang.annotation.RetentionPolicy.RUNTIME;
2020

2121
/**
22-
* Registers the BasicJavaType to use for the given {@link #javaType}
22+
* Registers a {@link BasicJavaType} as the default Java type descriptor for the given
23+
* {@link #javaType}.
2324
* <p>
2425
* Registrations applied to a package are processed before Hibernate begins to process
2526
* any attributes, etc.
2627
* <p>
2728
* Registrations applied to a class are only applied once Hibernate begins to process
28-
* that class; it will also affect all future processing. However, it will not change
29-
* previous resolutions to use this newly registered one. Because of this randomness
29+
* that class; it will also affect all future processing. However, it will not change
30+
* previous resolutions to use this newly registered one. Due to this nondeterminism,
3031
* it is recommended to only apply registrations to packages or to use a
3132
* {@link org.hibernate.boot.model.TypeContributor}.
3233
*
34+
* @implNote {@link BasicJavaType} registrations are maintained by the
35+
* {@link org.hibernate.type.descriptor.java.spi.JavaTypeRegistry}.
36+
*
3337
* @since 6.0
3438
*/
3539
@Target({PACKAGE, TYPE, ANNOTATION_TYPE})

hibernate-core/src/main/java/org/hibernate/annotations/JdbcTypeRegistration.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,33 @@
1212
import java.lang.annotation.Target;
1313

1414
import org.hibernate.type.descriptor.jdbc.JdbcType;
15-
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
1615

1716
import static java.lang.annotation.ElementType.PACKAGE;
1817
import static java.lang.annotation.ElementType.TYPE;
1918
import static java.lang.annotation.RetentionPolicy.RUNTIME;
2019

2120
/**
22-
* Describes a SqlTypeDescriptor to be added to the {@link JdbcTypeRegistry}
21+
* Registers a {@link JdbcType} as the default JDBC type descriptor for a certain
22+
* {@linkplain org.hibernate.type.SqlTypes type code}. The type code is determined by:
23+
* <ol>
24+
* <li>{@link #registrationCode}, if specified, or
25+
* <li>{@link JdbcType#getJdbcTypeCode()}.
26+
* </ol>
2327
* <p>
2428
* Registrations applied to a package are processed before Hibernate begins to process
2529
* any attributes, etc.
2630
* <p>
2731
* Registrations applied to a class are only applied once Hibernate begins to process
28-
* that class; it will also affect all future processing. However, it will not change
29-
* previous resolutions to use this newly registered one. Because of this randomness
32+
* that class; it will also affect all future processing. However, it will not change
33+
* previous resolutions to use this newly registered one. Due to this nondeterminism,
3034
* it is recommended to only apply registrations to packages or to use a
3135
* {@link org.hibernate.boot.model.TypeContributor}.
3236
*
3337
* @see org.hibernate.boot.model.TypeContributor
3438
*
39+
* @implNote {@link JdbcType} registrations are maintained by the
40+
* {@link org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry}.
41+
*
3542
* @since 6.0
3643
*/
3744
@Target({PACKAGE, TYPE})

hibernate-core/src/main/java/org/hibernate/annotations/TypeRegistration.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
/**
2121
* Registers a custom {@linkplain UserType user type} implementation
22-
* to be used by default for all references to a particular basic type.
22+
* to be used by default for all references to a particular class of
23+
* {@linkplain jakarta.persistence.Basic basic type}.
2324
* <p>
2425
* May be overridden for a specific entity field or property using
2526
* {@link Type @Type}.
@@ -36,6 +37,13 @@
3637
@Retention( RUNTIME )
3738
@Repeatable( TypeRegistrations.class )
3839
public @interface TypeRegistration {
40+
/**
41+
* The basic type described by the {@link #userType}.
42+
*/
3943
Class<?> basicClass();
44+
45+
/**
46+
* The {@link UserType}.
47+
*/
4048
Class<? extends UserType<?>> userType();
4149
}

hibernate-core/src/main/java/org/hibernate/annotations/UuidGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum Style {
3939
RANDOM,
4040
/**
4141
* Applies a time-based generation strategy consistent with IETF RFC 4122.
42-
* Uses IP address rather than mac address.
42+
* Uses IP address rather than MAC address.
4343
*
4444
* @implNote Can be a bottleneck due to the need to synchronize in order
4545
* to increment an internal count as part of the algorithm.

hibernate-core/src/main/java/org/hibernate/annotations/package-info.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@
122122
* <li>{@link org.hibernate.annotations.Nationalized}
123123
* </ul>
124124
* <li><p>
125+
* Furthermore, a {@link org.hibernate.annotations.JavaTypeRegistration} or
126+
* {@link org.hibernate.annotations.JdbcTypeRegistration} allows the choice
127+
* of {@code JavaType} or {@code JdbcType} to be made <em>implicitly</em>.
128+
* <li><p>
125129
* A compositional type mapping also comes with a
126130
* {@link org.hibernate.type.descriptor.java.MutabilityPlan}, which is usually
127131
* chosen by the {@code JavaType}, but which may be overridden using the
@@ -133,12 +137,15 @@
133137
* all come in specialized flavors for handling map keys, list indexes, and so on.
134138
* <li><p>
135139
* Alternatively, a program may implement the {@link org.hibernate.usertype.UserType}
136-
* interface and associate it with a field or property explicitly using the
137-
* {@link org.hibernate.annotations.Type @Type} annotation, or implicitly using the
138-
* {@link org.hibernate.annotations.TypeRegistration @TypeRegistration} annotation.
140+
* interface and associate it with a field or property
141+
* <ul>
142+
* <li>explicitly, using the {@link org.hibernate.annotations.Type @Type} annotation,
143+
* or
144+
* <li>implicitly, using the {@link org.hibernate.annotations.TypeRegistration @TypeRegistration}
145+
* annotation.
146+
* </ul>
139147
* <p>
140148
* There are some specialized flavors of the {@code @Type} annotation too.
141-
* </li>
142149
* </ul>
143150
* <p>
144151
* These two approaches cannot be used together. A {@code UserType} always takes precedence
@@ -165,6 +172,21 @@
165172
* See the <em>User Guide</em> or the package {@link org.hibernate.type} for further
166173
* discussion.
167174
*
175+
* <h3 id="composite-types">Composite types</h3>
176+
*
177+
* A <em>composite type</em> is a type which maps to multiple columns. An example of a
178+
* composite type is an {@linkplain jakarta.persistence.Embeddable embeddable} object,
179+
* but this is not the only sort of composite type in Hibernate.
180+
* <p>
181+
* A program may implement the {@link org.hibernate.usertype.CompositeUserType}
182+
* interface and associate it with a field or property:
183+
* <ul>
184+
* <li>explicitly, using the {@link org.hibernate.annotations.CompositeType @CompositeType}
185+
* annotation, or
186+
* <li>implicitly, using the {@link org.hibernate.annotations.CompositeTypeRegistration @CompositeTypeRegistration}
187+
* annotation.
188+
* </ul>
189+
*
168190
* <h3 id="second-level-cache">Second level cache</h3>
169191
* <p>
170192
* When we make a decision to store an entity in the second-level cache, we must decide

hibernate-core/src/main/java/org/hibernate/boot/internal/IdGeneratorInterpreterImpl.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class IdGeneratorInterpreterImpl implements IdGeneratorStrategyInterpreter {
3131
private static final CoreMessageLogger log = CoreLogging.messageLogger( IdGeneratorInterpreterImpl.class );
3232

33-
private IdGeneratorStrategyInterpreter fallbackInterpreter = FallbackInterpreter.INSTANCE;
33+
private final IdGeneratorStrategyInterpreter fallbackInterpreter = FallbackInterpreter.INSTANCE;
3434
private ArrayList<IdGeneratorStrategyInterpreter> delegates;
3535

3636
@Override
@@ -88,16 +88,13 @@ private static class FallbackInterpreter implements IdGeneratorStrategyInterpret
8888
@Override
8989
public String determineGeneratorName(GenerationType generationType, GeneratorNameDeterminationContext context) {
9090
switch ( generationType ) {
91-
case IDENTITY: {
91+
case IDENTITY:
9292
return "identity";
93-
}
94-
case SEQUENCE: {
93+
case SEQUENCE:
9594
return SequenceStyleGenerator.class.getName();
96-
}
97-
case TABLE: {
95+
case TABLE:
9896
return org.hibernate.id.enhanced.TableGenerator.class.getName();
99-
}
100-
case AUTO: {
97+
case AUTO:
10198
if ( "increment".equalsIgnoreCase( context.getGeneratedValueGeneratorName() ) ) {
10299
return IncrementGenerator.class.getName();
103100
}
@@ -108,14 +105,12 @@ public String determineGeneratorName(GenerationType generationType, GeneratorNam
108105
}
109106

110107
return SequenceStyleGenerator.class.getName();
111-
}
112-
default: {
108+
default:
113109
// UNKNOWN
114110
if ( "UUID".equals( generationType.name() ) ) {
115111
return UUIDGenerator.class.getName();
116112
}
117113
throw new UnsupportedOperationException( "Unsupported generation type:" + generationType );
118-
}
119114
}
120115
}
121116

hibernate-core/src/main/java/org/hibernate/boot/model/IdentifierGeneratorDefinition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.hibernate.AssertionFailure;
1717
import org.hibernate.Internal;
1818
import org.hibernate.id.IdentifierGenerator;
19-
import org.hibernate.internal.util.collections.CollectionHelper;
2019

2120
import jakarta.persistence.GenerationType;
2221
import jakarta.persistence.Index;
@@ -26,6 +25,7 @@
2625

2726
import static java.util.Collections.emptyMap;
2827
import static java.util.Collections.unmodifiableMap;
28+
import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty;
2929

3030
/**
3131
* Models the definition of an {@linkplain org.hibernate.id.IdentityGenerator identifier generator}
@@ -47,7 +47,7 @@ public IdentifierGeneratorDefinition(
4747
final Map<String, String> parameters) {
4848
this.name = name;
4949
this.strategy = strategy;
50-
this.parameters = CollectionHelper.isEmpty( parameters ) ? emptyMap() : unmodifiableMap( parameters );
50+
this.parameters = isEmpty( parameters ) ? emptyMap() : unmodifiableMap( parameters );
5151
}
5252

5353
public IdentifierGeneratorDefinition(

hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import org.hibernate.jpa.SpecHints;
2424
import org.hibernate.query.spi.QueryPlan;
2525
import org.hibernate.query.sqm.NullPrecedence;
26+
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableStrategy;
27+
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableStrategy;
28+
import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableStrategy;
2629
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
2730
import org.hibernate.resource.jdbc.spi.StatementInspector;
2831

@@ -41,6 +44,11 @@
4144
* <li>via {@link Configuration#setProperty(String, String)}, or
4245
* <li>via {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder#applySetting(String, Object)}.
4346
* </ul>
47+
* <p>
48+
* Note that Hibernate does not distinguish between JPA-defined configuration
49+
* properties and "native" configuration properties. Any property listed here
50+
* may be used to configure Hibernate no matter what configuration mechanism
51+
* or bootstrap API is used.
4452
*
4553
* @author Steve Ebersole
4654
*/
@@ -894,6 +902,7 @@ public interface AvailableSettings {
894902
*
895903
* @deprecated {@code hbm.xml} mappings are no longer supported, making this attribute irrelevant
896904
*/
905+
@SuppressWarnings("DeprecatedIsStillUsed")
897906
@Deprecated(since = "6", forRemoval = true)
898907
String ARTIFACT_PROCESSING_ORDER = "hibernate.mapping.precedence";
899908

@@ -1159,6 +1168,7 @@ public interface AvailableSettings {
11591168
* @deprecated Will be removed without replacement. See HHH-15631
11601169
*/
11611170
@Deprecated(forRemoval = true)
1171+
@SuppressWarnings("DeprecatedIsStillUsed")
11621172
String USE_REFLECTION_OPTIMIZER = "hibernate.bytecode.use_reflection_optimizer";
11631173

11641174
/**
@@ -1408,6 +1418,7 @@ public interface AvailableSettings {
14081418
* @deprecated this is only honored for {@code hibernate-infinispan}
14091419
*/
14101420
@Deprecated
1421+
@SuppressWarnings("DeprecatedIsStillUsed")
14111422
String CACHE_KEYS_FACTORY = "hibernate.cache.keys_factory";
14121423

14131424
/**
@@ -1685,10 +1696,10 @@ public interface AvailableSettings {
16851696
* For cases where the {@value #HBM2DDL_SCRIPTS_ACTION} value indicates that schema commands
16861697
* should be written to DDL script file, specifies if schema commands should be appended to
16871698
* the end of the file rather than written at the beginning of the file.
1688-
*
1699+
* <p>
16891700
* Values are: {@code true} for appending schema commands to the end of the file, {@code false}
16901701
* for writing schema commands at the beginning.
1691-
*
1702+
* <p>
16921703
* The default value is {@code true}
16931704
*/
16941705
String HBM2DDL_SCRIPTS_CREATE_APPEND = "hibernate.hbm2ddl.schema-generation.script.append";
@@ -2467,6 +2478,7 @@ public interface AvailableSettings {
24672478
* no {@code @OrderColumn}.
24682479
*/
24692480
@Deprecated( since = "6.0" )
2481+
@SuppressWarnings("DeprecatedIsStillUsed")
24702482
String JPA_LIST_COMPLIANCE = "hibernate.jpa.compliance.list";
24712483

24722484
/**
@@ -3091,13 +3103,15 @@ public interface AvailableSettings {
30913103
* @deprecated Will be removed without replacement. See HHH-15641
30923104
*/
30933105
@Deprecated(forRemoval = true)
3106+
@SuppressWarnings("DeprecatedIsStillUsed")
30943107
String ENHANCER_ENABLE_DIRTY_TRACKING = "hibernate.enhancer.enableDirtyTracking";
30953108

30963109
/**
30973110
* Enable lazy loading feature in runtime bytecode enhancement
30983111
*
30993112
* @deprecated Will be removed without replacement. See HHH-15641
31003113
*/
3114+
@SuppressWarnings("DeprecatedIsStillUsed")
31013115
@Deprecated(forRemoval = true)
31023116
String ENHANCER_ENABLE_LAZY_INITIALIZATION = "hibernate.enhancer.enableLazyInitialization";
31033117

@@ -3148,20 +3162,47 @@ public interface AvailableSettings {
31483162
String VALIDATE_XML = "hibernate.validate_xml";
31493163

31503164
/**
3151-
* Enables processing `hbm.xml` mappings by transforming them to `mapping.xml` and using
3165+
* Enables processing {@code hbm.xml} mappings by transforming them to {@code mapping.xml} and using
31523166
* that processor. Default is false, must be opted-into.
31533167
*
31543168
* @since 6.1
31553169
*/
31563170
String TRANSFORM_HBM_XML = "hibernate.transform_hbm_xml.enabled";
31573171

31583172
/**
3159-
* How features in a `hbm.xml` file which are not supported for transformation should be handled.
3173+
* How features in a {@code hbm.xml} file which are not supported for transformation should be handled.
31603174
* <p>
31613175
* Default is {@link org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling#ERROR}
31623176
*
31633177
* @see org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling
31643178
* @since 6.1
31653179
*/
31663180
String TRANSFORM_HBM_XML_FEATURE_HANDLING = "hibernate.transform_hbm_xml.unsupported_feature_handling";
3181+
3182+
/**
3183+
* Allows creation of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#PERSISTENT persistent}
3184+
* temporary tables at application startup to be disabled. By default, table creation is enabled.
3185+
*/
3186+
String BULK_ID_STRATEGY_PERSISTENT_TEMPORARY_CREATE_TABLES = PersistentTableStrategy.CREATE_ID_TABLES;
3187+
/**
3188+
* Allows dropping of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#PERSISTENT persistent}
3189+
* temporary tables at application shutdown to be disabled. By default, table dropping is enabled.
3190+
*/
3191+
String BULK_ID_STRATEGY_PERSISTENT_TEMPORARY_DROP_TABLES = PersistentTableStrategy.DROP_ID_TABLES;
3192+
/**
3193+
* Allows creation of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#GLOBAL global}
3194+
* temporary tables at application startup to be disabled. By default, table creation is enabled.
3195+
*/
3196+
String BULK_ID_STRATEGY_GLOBAL_TEMPORARY_CREATE_TABLES = GlobalTemporaryTableStrategy.CREATE_ID_TABLES;
3197+
/**
3198+
* Allows dropping of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#GLOBAL global}
3199+
* temporary tables at application shutdown to be disabled. By default, table dropping is enabled.
3200+
*/
3201+
String BULK_ID_STRATEGY_GLOBAL_TEMPORARY_DROP_TABLES = GlobalTemporaryTableStrategy.DROP_ID_TABLES;
3202+
/**
3203+
* Allows dropping of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#LOCAL local}
3204+
* temporary tables at transaction commit to be enabled. By default, table dropping is disabled,
3205+
* and the database will drop the temporary tables automatically.
3206+
*/
3207+
String BULK_ID_STRATEGY_LOCAL_TEMPORARY_DROP_TABLES = LocalTemporaryTableStrategy.DROP_ID_TABLES;
31673208
}

0 commit comments

Comments
 (0)