Skip to content

Commit 1598d66

Browse files
yrodieresebersole
authored andcommitted
Revert "HHH-14584 Allow PhysicalNamingStrategy implementations to detect when a name is implicit or explicit"
This reverts commit 31ce5d3. This reverts commit d50563a.
1 parent ec1f8b0 commit 1598d66

File tree

17 files changed

+18
-283
lines changed

17 files changed

+18
-283
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -935,11 +935,6 @@ public Identifier toIdentifier(String text, boolean quoted) {
935935
return normalizeQuoting( Identifier.toIdentifier( text, quoted ) );
936936
}
937937

938-
@Override
939-
public Identifier toIdentifier(String text, boolean quoted, boolean isExplicit) {
940-
return normalizeQuoting( Identifier.toIdentifier( text, quoted, isExplicit ) );
941-
}
942-
943938
@Override
944939
public Identifier normalizeQuoting(Identifier identifier) {
945940
Identifier normalizedIdentifier = this.helper.normalizeQuoting( identifier );

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,15 +900,14 @@ public Table addTable(
900900
String name,
901901
String subselectFragment,
902902
boolean isAbstract,
903-
MetadataBuildingContext buildingContext,
904-
boolean isExplicit) {
903+
MetadataBuildingContext buildingContext) {
905904
final Namespace namespace = getDatabase().locateNamespace(
906905
getDatabase().toIdentifier( catalogName ),
907906
getDatabase().toIdentifier( schemaName )
908907
);
909908
// annotation binding depends on the "table name" for @Subselect bindings
910909
// being set into the generated table (mainly to avoid later NPE), but for now we need to keep that :(
911-
final Identifier logicalName = name != null ? getDatabase().toIdentifier( name, isExplicit ) : null;
910+
final Identifier logicalName = name != null ? getDatabase().toIdentifier( name ) : null;
912911
if ( subselectFragment != null ) {
913912
return new Table( buildingContext.getCurrentContributorName(),
914913
namespace, logicalName, subselectFragment, isAbstract );

hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,9 @@ public boolean isNameDeferred() {
353353
* @return {@code true} if a name could be inferred
354354
*/
355355
boolean inferColumnNameIfPossible(String columnName, String propertyName, boolean applyNamingStrategy) {
356-
if ( isNotEmpty( columnName ) || isNotEmpty( propertyName ) ) {
356+
if ( !isEmpty( columnName ) || !isEmpty( propertyName ) ) {
357357
final String logicalColumnName = resolveLogicalColumnName( columnName, propertyName );
358-
mappingColumn.setName(
359-
processColumnName( logicalColumnName, applyNamingStrategy, isNotEmpty( columnName ) ) );
358+
mappingColumn.setName( processColumnName( logicalColumnName, applyNamingStrategy ) );
360359
return true;
361360
}
362361
else {
@@ -404,12 +403,11 @@ private String applyEmbeddedColumnNaming(String inferredColumnName, ComponentPro
404403
return result;
405404
}
406405

407-
protected String processColumnName(String columnName, boolean applyNamingStrategy, boolean isExplicit) {
406+
protected String processColumnName(String columnName, boolean applyNamingStrategy) {
408407
if ( applyNamingStrategy ) {
409408
final var database = getDatabase();
410409
return getPhysicalNamingStrategy()
411-
.toPhysicalColumnName( database.toIdentifier( columnName, isExplicit ),
412-
database.getJdbcEnvironment() )
410+
.toPhysicalColumnName( database.toIdentifier( columnName ), database.getJdbcEnvironment() )
413411
.render( database.getDialect() );
414412
}
415413
else {

hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedJoinColumn.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,7 @@ public void overrideFromReferencedColumnIfNecessary(Column column) {
458458
@Override
459459
boolean inferColumnNameIfPossible(String columnName, String propertyName, boolean applyNamingStrategy) {
460460
if ( isNotEmpty( columnName ) ) {
461-
getMappingColumn().setName(
462-
processColumnName( columnName, applyNamingStrategy, isNotEmpty( columnName ) ) );
461+
getMappingColumn().setName( processColumnName( columnName, applyNamingStrategy ) );
463462
return true;
464463
}
465464
else {

hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,8 +1760,7 @@ public MetadataBuildingContext getBuildingContext() {
17601760

17611761
@Override
17621762
public Identifier handleExplicitName(String explicitName, MetadataBuildingContext buildingContext) {
1763-
return jdbcEnvironment( buildingContext ).getIdentifierHelper()
1764-
.toIdentifier( explicitName, false, true );
1763+
return jdbcEnvironment( buildingContext ).getIdentifierHelper().toIdentifier( explicitName );
17651764
}
17661765

17671766
@Override

hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,7 @@ private static Table addTable(
542542
logicalName.render(),
543543
subselect,
544544
isAbstract,
545-
buildingContext,
546-
logicalName.isExplicit()
545+
buildingContext
547546
);
548547
}
549548
}

hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
public class Identifier implements Comparable<Identifier> {
2424
private final String text;
2525
private final boolean isQuoted;
26-
private final boolean isExplicit;
2726

2827
/**
2928
* Means to generate an {@link Identifier} instance from its simple text form.
@@ -63,7 +62,7 @@ public static Identifier toIdentifier(String text) {
6362
* @return The identifier form, or {@code null} if text was {@code null}
6463
*/
6564
public static Identifier toIdentifier(String text, boolean quote) {
66-
return toIdentifier( text, quote, true, false );
65+
return toIdentifier( text, quote, true );
6766
}
6867

6968
/**
@@ -82,25 +81,6 @@ public static Identifier toIdentifier(String text, boolean quote) {
8281
* @return The identifier form, or {@code null} if text was {@code null}
8382
*/
8483
public static Identifier toIdentifier(String text, boolean quote, boolean autoquote) {
85-
return toIdentifier( text, quote, autoquote, false );
86-
}
87-
88-
/**
89-
* Means to generate an {@link Identifier} instance from its simple text form.
90-
* <p>
91-
* If passed {@code text} is {@code null}, {@code null} is returned.
92-
* <p>
93-
* If passed {@code text} is surrounded in quote markers, the returned Identifier
94-
* is considered quoted. Quote markers include back-ticks (`), double-quotes ("),
95-
* and brackets ([ and ]).
96-
*
97-
* @param text The text form
98-
* @param quote Whether to quote unquoted text forms
99-
* @param autoquote Whether to quote the result if it contains special characters
100-
* @param isExplicit Whether the name is explicitly set
101-
* @return The identifier form, or {@code null} if text was {@code null}
102-
*/
103-
public static Identifier toIdentifier(String text, boolean quote, boolean autoquote, boolean isExplicit) {
10484
if ( isBlank( text ) ) {
10585
return null;
10686
}
@@ -126,7 +106,7 @@ public static Identifier toIdentifier(String text, boolean quote, boolean autoqu
126106
else if ( autoquote && !quote ) {
127107
quote = autoquote( text, start, end );
128108
}
129-
return new Identifier( text.substring( start, end ), quote, isExplicit );
109+
return new Identifier( text.substring( start, end ), quote );
130110
}
131111

132112
private static boolean autoquote(String text, int start, int end) {
@@ -204,17 +184,6 @@ public static String unQuote(String name) {
204184
* @param quoted Is this a quoted identifier?
205185
*/
206186
public Identifier(String text, boolean quoted) {
207-
this( text, quoted, false );
208-
}
209-
210-
/**
211-
* Constructs an identifier instance.
212-
*
213-
* @param text The identifier text.
214-
* @param quoted Is this a quoted identifier?
215-
* @param isExplicit Whether the name is explicitly set
216-
*/
217-
public Identifier(String text, boolean quoted, boolean isExplicit) {
218187
if ( isEmpty( text ) ) {
219188
throw new IllegalIdentifierException( "Identifier text cannot be null" );
220189
}
@@ -223,7 +192,6 @@ public Identifier(String text, boolean quoted, boolean isExplicit) {
223192
}
224193
this.text = text;
225194
this.isQuoted = quoted;
226-
this.isExplicit = isExplicit;
227195
}
228196

229197
/**
@@ -234,7 +202,6 @@ public Identifier(String text, boolean quoted, boolean isExplicit) {
234202
protected Identifier(String text) {
235203
this.text = text;
236204
this.isQuoted = false;
237-
this.isExplicit = false;
238205
}
239206

240207
/**
@@ -328,8 +295,4 @@ public static boolean areEqual(Identifier id1, Identifier id2) {
328295
public static Identifier quote(Identifier identifier) {
329296
return identifier.quoted();
330297
}
331-
332-
public boolean isExplicit() {
333-
return isExplicit;
334-
}
335298
}

hibernate-core/src/main/java/org/hibernate/boot/model/relational/Database.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,7 @@ public JdbcEnvironment getJdbcEnvironment() {
103103
* @return The wrapped Identifier form
104104
*/
105105
public Identifier toIdentifier(String text) {
106-
return toIdentifier( text, false );
107-
}
108-
109-
/**
110-
* Wrap the raw name of a database object in its Identifier form accounting
111-
* for quoting from any of:
112-
* <ul>
113-
* <li>explicit quoting in the name itself</li>
114-
* <li>global request to quote all identifiers</li>
115-
* </ul>
116-
*
117-
* @param text The raw object name
118-
* @param isExplicit Whether the name is explicitly set
119-
* @return The wrapped Identifier form
120-
* @implNote Quoting from database keywords happens only when building physical identifiers.
121-
*/
122-
public Identifier toIdentifier(String text, boolean isExplicit) {
123-
return text == null ? null : jdbcEnvironment.getIdentifierHelper().toIdentifier( text, false, isExplicit );
106+
return text == null ? null : jdbcEnvironment.getIdentifierHelper().toIdentifier( text );
124107
}
125108

126109
public PhysicalNamingStrategy getPhysicalNamingStrategy() {

hibernate-core/src/main/java/org/hibernate/boot/model/relational/QualifiedNameParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public NameParts parse(String text, Identifier defaultCatalog, Identifier defaul
110110

111111
if ( isQuotedInEntirety( text ) ) {
112112
return new NameParts( defaultCatalog, defaultSchema,
113-
Identifier.toIdentifier( unquote( text ), true, true, true ) );
113+
Identifier.toIdentifier( unquote( text ), true ) );
114114
}
115115

116116
String catalogName = null;
@@ -169,7 +169,7 @@ else if ( defaultCatalog != null ) {
169169
return new NameParts(
170170
Identifier.toIdentifier( catalogName, catalogWasQuoted ),
171171
Identifier.toIdentifier( schemaName, schemaWasQuoted ),
172-
Identifier.toIdentifier( name, nameWasQuoted, true, true )
172+
Identifier.toIdentifier( name, nameWasQuoted )
173173
);
174174
}
175175

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ default AnnotationDescriptorRegistry getAnnotationDescriptorRegistry() {
140140
* @param subselect A select statement which defines a logical table, much
141141
* like a DB view.
142142
* @param isAbstract Is the table abstract (i.e. not really existing in the DB)?
143-
* @param isExplicit Whether the name is explicitly set
144143
*
145144
* @return The created table metadata, or the existing reference.
146145
*/
@@ -150,8 +149,7 @@ Table addTable(
150149
String name,
151150
String subselect,
152151
boolean isAbstract,
153-
MetadataBuildingContext buildingContext,
154-
boolean isExplicit);
152+
MetadataBuildingContext buildingContext);
155153

156154
/**
157155
* Adds a 'denormalized table' to this repository.

0 commit comments

Comments
 (0)