Skip to content

Commit ec0f78d

Browse files
committed
HHH-18649 populate TypedQueryReference in static metamodel
also rename two enums since "metamodel" is a word
1 parent 67e7b89 commit ec0f78d

File tree

14 files changed

+152
-82
lines changed

14 files changed

+152
-82
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,9 @@ public ParameterMemento toMemento(SessionFactoryImplementor sessionFactory) {
203203
private static String normalize(String name) {
204204
return StringHelper.isNotEmpty( name ) ? name : null;
205205
}
206+
207+
@Override
208+
public Map<String, Object> getHints() {
209+
return hints;
210+
}
206211
}

hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/SequenceGeneratorJpaAnnotation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public SequenceGeneratorJpaAnnotation(SourceModelBuildingContext modelContext) {
3232
/**
3333
* Used in creating named, defaulted annotation instances. Generally this
3434
* is a situation where we have:<ol>
35-
* <li>{@linkplain GeneratedValue#strategy()} set to {@linkplain jakarta.persistence.GenerationType#SEQUENCE}</li>
36-
* <li>{@linkplain GeneratedValue#generator()} set to a non-empty String, but with no matching {@linkplain SequenceGenerator}</li>
35+
* <li>{@linkplain jakarta.persistence.GeneratedValue#strategy()} set to {@linkplain jakarta.persistence.GenerationType#SEQUENCE}</li>
36+
* <li>{@linkplain jakarta.persistence.GeneratedValue#generator()} set to a non-empty String, but with no matching {@linkplain SequenceGenerator}</li>
3737
* </ol>
3838
*/
3939
public SequenceGeneratorJpaAnnotation(String name, SourceModelBuildingContext modelContext) {

hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/TableGeneratorJpaAnnotation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public TableGeneratorJpaAnnotation(SourceModelBuildingContext modelContext) {
4747
/**
4848
* Used in creating named, defaulted annotation instances. Generally this
4949
* is a situation where we have:<ol>
50-
* <li>{@linkplain GeneratedValue#strategy()} set to {@linkplain jakarta.persistence.GenerationType#TABLE}</li>
51-
* <li>{@linkplain GeneratedValue#generator()} set to a non-empty String, but with no matching {@linkplain TableGenerator}</li>
50+
* <li>{@linkplain jakarta.persistence.GeneratedValue#strategy()} set to {@linkplain jakarta.persistence.GenerationType#TABLE}</li>
51+
* <li>{@linkplain jakarta.persistence.GeneratedValue#generator()} set to a non-empty String, but with no matching {@linkplain TableGenerator}</li>
5252
* </ol>
5353
*/
5454
public TableGeneratorJpaAnnotation(String name, SourceModelBuildingContext modelContext) {

hibernate-core/src/main/java/org/hibernate/boot/query/NamedQueryDefinition.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@
44
*/
55
package org.hibernate.boot.query;
66

7+
import jakarta.persistence.TypedQueryReference;
78
import org.hibernate.engine.spi.SessionFactoryImplementor;
89
import org.hibernate.query.named.NamedQueryMemento;
910

1011
import org.checkerframework.checker.nullness.qual.Nullable;
1112

13+
1214
/**
1315
* Common attributes shared across the mapping of named HQL, native
1416
* and "callable" queries defined in annotations, orm.xml and hbm.xml
1517
*
1618
* @author Steve Ebersole
1719
* @author Gavin King
1820
*/
19-
public interface NamedQueryDefinition<E> {
21+
public interface NamedQueryDefinition<E> extends TypedQueryReference<E> {
22+
@Override
23+
default String getName() {
24+
return getRegistrationName();
25+
}
26+
2027
/**
2128
* The name under which the query is to be registered
2229
*/

hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractNamedQueryDefinition.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public String getComment() {
110110
return comment;
111111
}
112112

113+
@Override
113114
public Map<String, Object> getHints() {
114115
return hints;
115116
}

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,38 @@ public interface MappingSettings {
4646
/**
4747
* Setting that indicates whether to build the JPA types, either:<ul>
4848
* <li>
49-
* <b>enabled</b> - Do the build
49+
* {@code enabled} &mdash; do the build
5050
* </li>
5151
* <li>
52-
* <b>disabled</b> - Do not do the build
52+
* {@code disabled} &mdash; do not do the build
5353
* </li>
5454
* <li>
55-
* <b>ignoreUnsupported</b> - Do the build, but ignore any non-JPA
56-
* features that would otherwise result in a failure.
55+
* {@code ignoreUnsupported} &mdash; do the build, but ignore any
56+
* non-JPA features that would otherwise result in a failure.
5757
* </li>
5858
* </ul>
59+
*
60+
* @settingDefault {@code ignoreUnsupported}
5961
*/
6062
String JPA_METAMODEL_POPULATION = "hibernate.jpa.metamodel.population";
6163

6264
/**
63-
* Setting that controls whether we seek out JPA "static metamodel" classes
65+
* Setting that controls whether we seek out JPA static metamodel classes
6466
* and populate them, either:<ul>
6567
* <li>
66-
* <b>enabled</b> - Do the population
68+
* {@code enabled} &mdash; do populate the static metamodel,
6769
* </li>
6870
* <li>
69-
* <b>disabled</b> - Do not do the population
71+
* {@code disabled} &mdash; do not populate the static metamodel, or
7072
* </li>
7173
* <li>
72-
* <b>skipUnsupported</b> - Do the population, but ignore any non-JPA
73-
* features that would otherwise result in the population failing.
74+
* {@code skipUnsupported} &mdash; do populate the static metamodel,
75+
* but ignore any non-JPA features that would otherwise result in
76+
* the process failing.
7477
* </li>
7578
* </ul>
79+
*
80+
* @settingDefault {@code skipUnsupported}
7681
*/
7782
String STATIC_METAMODEL_POPULATION = "hibernate.jpa.static_metamodel.population";
7883

hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public void sessionFactoryClosed(SessionFactory factory) {
356356

357357
private void integrate(MetadataImplementor bootMetamodel, BootstrapContext bootstrapContext, IntegratorObserver integratorObserver) {
358358
for ( Integrator integrator : serviceRegistry.requireService( IntegratorService.class ).getIntegrators() ) {
359-
integrator.integrate(bootMetamodel, bootstrapContext, this );
359+
integrator.integrate( bootMetamodel, bootstrapContext, this );
360360
integratorObserver.integrators.add( integrator );
361361
}
362362
}
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package org.hibernate.metamodel.internal;
66

7+
import java.util.Locale;
78
import java.util.Map;
89

910
import org.hibernate.cfg.AvailableSettings;
@@ -12,28 +13,25 @@
1213
/**
1314
* @author Steve Ebersole
1415
*/
15-
public enum JpaMetaModelPopulationSetting {
16+
public enum JpaMetamodelPopulationSetting {
1617
ENABLED,
1718
DISABLED,
1819
IGNORE_UNSUPPORTED;
1920

20-
public static JpaMetaModelPopulationSetting parse(String setting) {
21-
if ( "enabled".equalsIgnoreCase( setting ) ) {
22-
return ENABLED;
23-
}
24-
else if ( "disabled".equalsIgnoreCase( setting ) ) {
25-
return DISABLED;
26-
}
27-
else {
28-
return IGNORE_UNSUPPORTED;
29-
}
21+
public static JpaMetamodelPopulationSetting parse(String setting) {
22+
return switch ( setting.toLowerCase(Locale.ROOT) ) {
23+
case "enabled" -> ENABLED;
24+
case "disabled" -> DISABLED;
25+
default -> IGNORE_UNSUPPORTED;
26+
};
3027
}
3128

32-
public static JpaMetaModelPopulationSetting determineJpaMetaModelPopulationSetting(Map configurationValues) {
29+
public static JpaMetamodelPopulationSetting determineJpaMetaModelPopulationSetting(Map configurationValues) {
3330
String setting = ConfigurationHelper.getString(
3431
AvailableSettings.JPA_METAMODEL_POPULATION,
35-
configurationValues
32+
configurationValues,
33+
"ignoreUnsupported"
3634
);
37-
return JpaMetaModelPopulationSetting.parse( setting );
35+
return JpaMetamodelPopulationSetting.parse( setting );
3836
}
3937
}
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package org.hibernate.metamodel.internal;
66

7+
import java.util.Locale;
78
import java.util.Map;
89

910
import org.hibernate.cfg.AvailableSettings;
@@ -15,43 +16,40 @@
1516
*
1617
* @author Andrea Boriero
1718
*/
18-
public enum JpaStaticMetaModelPopulationSetting {
19+
public enum JpaStaticMetamodelPopulationSetting {
1920
/**
20-
* ENABLED indicates that Hibernate will look for the JPA static metamodel description
21+
* Indicates that Hibernate will look for the JPA static metamodel description
2122
* of the application domain model and populate it.
2223
*/
2324
ENABLED,
2425
/**
25-
* DISABLED indicates that Hibernate will not look for the JPA static metamodel description
26+
* Indicates that Hibernate will not look for the JPA static metamodel description
2627
* of the application domain model.
2728
*/
2829
DISABLED,
2930
/**
30-
* SKIP_UNSUPPORTED works as ENABLED but ignores any non-JPA features that would otherwise
31+
* Works as {@link #ENABLED} but ignores any non-JPA features that would otherwise
3132
* result in the population failing.
3233
*/
3334
SKIP_UNSUPPORTED;
3435

35-
public static JpaStaticMetaModelPopulationSetting parse(String setting) {
36-
if ( "enabled".equalsIgnoreCase( setting ) ) {
37-
return ENABLED;
38-
}
39-
else if ( "disabled".equalsIgnoreCase( setting ) ) {
40-
return DISABLED;
41-
}
42-
else {
43-
return SKIP_UNSUPPORTED;
44-
}
36+
public static JpaStaticMetamodelPopulationSetting parse(String setting) {
37+
return switch ( setting.toLowerCase(Locale.ROOT) ) {
38+
case "enabled" -> ENABLED;
39+
case "disabled" -> DISABLED;
40+
default -> SKIP_UNSUPPORTED;
41+
};
4542
}
4643

47-
public static JpaStaticMetaModelPopulationSetting determineJpaStaticMetaModelPopulationSetting(Map configurationValues) {
44+
public static JpaStaticMetamodelPopulationSetting determineJpaStaticMetaModelPopulationSetting(Map configurationValues) {
4845
return parse( determineSetting( configurationValues ) );
4946
}
5047

5148
private static String determineSetting(Map configurationValues) {
5249
return ConfigurationHelper.getString(
5350
AvailableSettings.STATIC_METAMODEL_POPULATION,
54-
configurationValues
51+
configurationValues,
52+
"skipUnsupported"
5553
);
5654
}
5755
}

0 commit comments

Comments
 (0)