77import org .hibernate .Incubating ;
88import org .hibernate .boot .model .TypeDefinitionRegistry ;
99import org .hibernate .boot .model .naming .ObjectNameNormalizer ;
10- import org .hibernate .cfg . MappingSettings ;
10+ import org .hibernate .boot . registry . StandardServiceRegistry ;
1111import org .hibernate .engine .config .spi .ConfigurationService ;
1212import org .hibernate .internal .util .config .ConfigurationHelper ;
1313import org .hibernate .service .ServiceRegistry ;
1414
15+ import static org .hibernate .cfg .MappingSettings .JAVA_TIME_USE_DIRECT_JDBC ;
16+ import static org .hibernate .cfg .MappingSettings .PREFER_LOCALE_LANGUAGE_TAG ;
17+ import static org .hibernate .cfg .MappingSettings .PREFER_NATIVE_ENUM_TYPES ;
18+ import static org .hibernate .internal .util .config .ConfigurationHelper .getBoolean ;
19+
1520/**
1621 * Describes the context in which the process of building {@link org.hibernate.boot.Metadata}
1722 * from {@link org.hibernate.boot.MetadataSources} occurs.
@@ -53,44 +58,48 @@ public interface MetadataBuildingContext {
5358 */
5459 ObjectNameNormalizer getObjectNameNormalizer ();
5560
61+ private StandardServiceRegistry getRegistry () {
62+ return getBootstrapContext ().getServiceRegistry ();
63+ }
64+
5665 @ Incubating
5766 default int getPreferredSqlTypeCodeForBoolean () {
58- return ConfigurationHelper .getPreferredSqlTypeCodeForBoolean ( getBootstrapContext (). getServiceRegistry () );
67+ return ConfigurationHelper .getPreferredSqlTypeCodeForBoolean ( getRegistry () );
5968 }
6069
6170 @ Incubating
6271 default int getPreferredSqlTypeCodeForDuration () {
63- return ConfigurationHelper .getPreferredSqlTypeCodeForDuration ( getBootstrapContext (). getServiceRegistry () );
72+ return ConfigurationHelper .getPreferredSqlTypeCodeForDuration ( getRegistry () );
6473 }
6574
6675 @ Incubating
6776 default int getPreferredSqlTypeCodeForUuid () {
68- return ConfigurationHelper .getPreferredSqlTypeCodeForUuid ( getBootstrapContext (). getServiceRegistry () );
77+ return ConfigurationHelper .getPreferredSqlTypeCodeForUuid ( getRegistry () );
6978 }
7079
7180 @ Incubating
7281 default int getPreferredSqlTypeCodeForInstant () {
73- return ConfigurationHelper .getPreferredSqlTypeCodeForInstant ( getBootstrapContext (). getServiceRegistry () );
82+ return ConfigurationHelper .getPreferredSqlTypeCodeForInstant ( getRegistry () );
7483 }
7584
7685 @ Incubating
7786 default int getPreferredSqlTypeCodeForArray () {
78- return ConfigurationHelper .getPreferredSqlTypeCodeForArray ( getBootstrapContext (). getServiceRegistry () );
87+ return ConfigurationHelper .getPreferredSqlTypeCodeForArray ( getRegistry () );
7988 }
8089
8190 @ Incubating
8291 default boolean isPreferJavaTimeJdbcTypesEnabled () {
83- return isPreferJavaTimeJdbcTypesEnabled ( getBootstrapContext (). getServiceRegistry () );
92+ return isPreferJavaTimeJdbcTypesEnabled ( getRegistry () );
8493 }
8594
8695 @ Incubating
8796 default boolean isPreferNativeEnumTypesEnabled () {
88- return isPreferNativeEnumTypesEnabled ( getBootstrapContext (). getServiceRegistry () );
97+ return isPreferNativeEnumTypesEnabled ( getRegistry () );
8998 }
9099
91100 @ Incubating
92101 default boolean isPreferLocaleLanguageTagEnabled () {
93- return isPreferLocaleLanguageTagEnabled ( getBootstrapContext (). getServiceRegistry () );
102+ return isPreferLocaleLanguageTagEnabled ( getRegistry () );
94103 }
95104
96105 static boolean isPreferJavaTimeJdbcTypesEnabled (ServiceRegistry serviceRegistry ) {
@@ -106,29 +115,16 @@ static boolean isPreferLocaleLanguageTagEnabled(ServiceRegistry serviceRegistry)
106115 }
107116
108117 static boolean isPreferJavaTimeJdbcTypesEnabled (ConfigurationService configurationService ) {
109- return ConfigurationHelper .getBoolean (
110- MappingSettings .JAVA_TIME_USE_DIRECT_JDBC ,
111- configurationService .getSettings (),
112- // todo : true would be better eventually so maybe just rip off that band aid
113- false
114- );
118+ return getBoolean ( JAVA_TIME_USE_DIRECT_JDBC , configurationService .getSettings () );
115119 }
116120
117121 static boolean isPreferNativeEnumTypesEnabled (ConfigurationService configurationService ) {
118- return ConfigurationHelper .getBoolean (
119- MappingSettings .PREFER_NATIVE_ENUM_TYPES ,
120- configurationService .getSettings (),
121- // todo: switch to true with HHH-17905
122- false
123- );
122+ //TODO: HHH-17905 proposes to switch this default to true
123+ return getBoolean ( PREFER_NATIVE_ENUM_TYPES , configurationService .getSettings () );
124124 }
125125
126126 static boolean isPreferLocaleLanguageTagEnabled (ConfigurationService configurationService ) {
127- return ConfigurationHelper .getBoolean (
128- MappingSettings .PREFER_LOCALE_LANGUAGE_TAG ,
129- configurationService .getSettings (),
130- false
131- );
127+ return getBoolean ( PREFER_LOCALE_LANGUAGE_TAG , configurationService .getSettings () );
132128 }
133129
134130 TypeDefinitionRegistry getTypeDefinitionRegistry ();
0 commit comments