Skip to content

Commit c9dc199

Browse files
committed
extract a method
1 parent 853b76a commit c9dc199

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ private Identifier columnIdentifier(
426426
ImplicitNamingStrategy implicitNamingStrategy,
427427
InFlightMetadataCollector collector,
428428
Database database) {
429-
boolean isRefColumnQuoted = isQuoted( logicalReferencedColumn );
429+
final boolean isRefColumnQuoted = isQuoted( logicalReferencedColumn );
430430

431431
if ( isMappedBySide() ) {
432432
// NOTE: An @ElementCollection can't be mappedBy, but the client code
@@ -439,17 +439,10 @@ private Identifier columnIdentifier(
439439
}
440440
else if ( isOwnerSide() ) {
441441
final String logicalTableName = collector.getLogicalTableName( referencedEntity.getTable() );
442-
Identifier columnIdentifier = implicitNamingStrategy.determineJoinColumnName(
443-
new OwnedImplicitJoinColumnNameSource(referencedEntity, logicalTableName, logicalReferencedColumn)
442+
final Identifier columnIdentifier = implicitNamingStrategy.determineJoinColumnName(
443+
new OwnedImplicitJoinColumnNameSource( referencedEntity, logicalTableName, logicalReferencedColumn )
444444
);
445-
// HHH-11826 magic. See AnnotatedColumn and the HHH-6005 comments
446-
if ( columnIdentifier.getText().contains( "_{element}_" ) ) {
447-
columnIdentifier = Identifier.toIdentifier(
448-
columnIdentifier.getText().replace( "_{element}_", "_" ),
449-
columnIdentifier.isQuoted()
450-
);
451-
}
452-
return quoteIfNecessary( isRefColumnQuoted, logicalTableName, columnIdentifier );
445+
return quoteIfNecessary( isRefColumnQuoted, logicalTableName, handleElement( columnIdentifier ) );
453446
}
454447
else {
455448
final Identifier logicalTableName = database.toIdentifier(
@@ -478,9 +471,23 @@ public Identifier getReferencedPrimaryKeyColumnName() {
478471
}
479472
}
480473

474+
private Identifier handleElement(Identifier columnIdentifier) {
475+
// HHH-11826 magic. See AnnotatedColumn and the HHH-6005 comments
476+
if ( columnIdentifier.getText().contains( "_{element}_" ) ) {
477+
return Identifier.toIdentifier(
478+
columnIdentifier.getText().replace( "_{element}_", "_" ),
479+
columnIdentifier.isQuoted()
480+
);
481+
}
482+
else {
483+
return columnIdentifier;
484+
}
485+
}
486+
481487
private static Identifier quoteIfNecessary(
482488
boolean isRefColumnQuoted, Identifier logicalTableName, Identifier columnIdentifier) {
483-
return !columnIdentifier.isQuoted() && ( isRefColumnQuoted || logicalTableName.isQuoted() )
489+
return !columnIdentifier.isQuoted()
490+
&& ( isRefColumnQuoted || logicalTableName.isQuoted() )
484491
? Identifier.quote( columnIdentifier )
485492
: columnIdentifier;
486493
}
@@ -591,8 +598,9 @@ public Identifier getReferencedColumnName() {
591598
return null;
592599
}
593600

594-
final Property mappedByProperty = collector.getEntityBinding( getMappedByEntityName() )
595-
.getProperty( getMappedByPropertyName() );
601+
final Property mappedByProperty =
602+
collector.getEntityBinding( getMappedByEntityName() )
603+
.getProperty( getMappedByPropertyName() );
596604
final SimpleValue value = (SimpleValue) mappedByProperty.getValue();
597605
if ( value.getSelectables().isEmpty() ) {
598606
throw new AnnotationException(

0 commit comments

Comments
 (0)