Skip to content

HHH-14584 Allow PhysicalNamingStrategy implementations to detect when a name is implicit or explicit #10366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

peter1123581321
Copy link
Contributor

@peter1123581321 peter1123581321 commented Jun 17, 2025

In HHH-14584, an additional field was requested in Identifier to indicate explicit namings of columns.
This would allow more possibilies in a custom PhysicalNamingStrategy.

As PhysicalNamingStrategy also provides methods for sequences and tables, this PR also implements handling explicit namings of both of them.
However, I did not provide it for schemas and catalogs.

Many thanks in advance for feedback, comments and change requests. :)


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-14584

Comment on lines 929 to 933
Identifier logicalName = null;
if ( name != null ) {
logicalName = getDatabase().toIdentifier( name );
logicalName.setExplicit( isExplicit );
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Identifier logicalName = null;
if ( name != null ) {
logicalName = getDatabase().toIdentifier( name );
logicalName.setExplicit( isExplicit );
}
final Identifier logicalName;
if ( name == null ) {
logicalName = null
}
else {
logicalName = getDatabase().toIdentifier( name );
logicalName.setExplicit( isExplicit );
}

if ( applyNamingStrategy ) {
final Database database = getDatabase();
Identifier identifier = database.toIdentifier( columnName );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Identifier identifier = database.toIdentifier( columnName );
final Identifier identifier = database.toIdentifier( columnName );

@@ -1773,7 +1773,10 @@ public MetadataBuildingContext getBuildingContext() {

@Override
public Identifier handleExplicitName(String explicitName, MetadataBuildingContext buildingContext) {
return jdbcEnvironment( buildingContext ).getIdentifierHelper().toIdentifier( explicitName );
Identifier identifier = jdbcEnvironment( buildingContext ).getIdentifierHelper()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Identifier identifier = jdbcEnvironment( buildingContext ).getIdentifierHelper()
final Identifier identifier = jdbcEnvironment( buildingContext ).getIdentifierHelper()

@@ -23,6 +23,7 @@
public class Identifier implements Comparable<Identifier> {
private final String text;
private final boolean isQuoted;
private boolean isExplicit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be better to keep Identifier is a completely immutable object, and overload Database.toIdentifier() to accept isExplicit is a parameter.

@@ -352,10 +352,12 @@ private static QualifiedName sequenceName(
IdentifierHelper identifierHelper) {
if ( isNotEmpty( explicitSequenceName ) ) {
// we have an explicit name, use it
return explicitSequenceName.contains(".")
QualifiedNameParser.NameParts nameParts = explicitSequenceName.contains( "." )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QualifiedNameParser.NameParts nameParts = explicitSequenceName.contains( "." )
final QualifiedNameParser.NameParts nameParts = explicitSequenceName.contains( "." )

@peter1123581321 peter1123581321 marked this pull request as draft June 18, 2025 16:11
@peter1123581321 peter1123581321 marked this pull request as draft June 18, 2025 16:11
@peter1123581321 peter1123581321 marked this pull request as ready for review June 19, 2025 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants