23
23
import org .hibernate .annotations .common .reflection .XClass ;
24
24
import org .hibernate .boot .model .naming .EntityNaming ;
25
25
import org .hibernate .boot .model .naming .Identifier ;
26
+ import org .hibernate .boot .model .naming .ImplicitBasicColumnNameSource ;
26
27
import org .hibernate .boot .model .naming .ImplicitJoinColumnNameSource ;
27
28
import org .hibernate .boot .model .naming .ImplicitNamingStrategy ;
28
29
import org .hibernate .boot .model .naming .ImplicitPrimaryKeyJoinColumnNameSource ;
@@ -495,7 +496,7 @@ private String buildDefaultColumnName(final PersistentClass referencedEntity, fi
495
496
final ImplicitNamingStrategy implicitNamingStrategy = getBuildingContext ().getBuildingOptions ().getImplicitNamingStrategy ();
496
497
final PhysicalNamingStrategy physicalNamingStrategy = getBuildingContext ().getBuildingOptions ().getPhysicalNamingStrategy ();
497
498
498
- String columnName ;
499
+ Identifier columnIdentifier ;
499
500
boolean mappedBySide = mappedByTableName != null || mappedByPropertyName != null ;
500
501
boolean ownerSide = getPropertyName () != null ;
501
502
@@ -505,8 +506,6 @@ private String buildDefaultColumnName(final PersistentClass referencedEntity, fi
505
506
: logicalReferencedColumn ;
506
507
507
508
if ( mappedBySide ) {
508
- final Identifier columnIdentifier ;
509
-
510
509
// NOTE : While it is completely misleading here to allow for the combination
511
510
// of a "JPA ElementCollection" to be mappedBy, the code that uses this
512
511
// class relies on this behavior for handling the inverse side of
@@ -579,7 +578,8 @@ public Identifier getReferencedColumnName() {
579
578
return null ;
580
579
}
581
580
582
- final PersistentClass mappedByEntityBinding = getBuildingContext ().getMetadataCollector ().getEntityBinding ( mappedByEntityName );
581
+ final PersistentClass mappedByEntityBinding = getBuildingContext ().getMetadataCollector ()
582
+ .getEntityBinding ( mappedByEntityName );
583
583
final Property mappedByProperty = mappedByEntityBinding .getProperty ( mappedByPropertyName );
584
584
final SimpleValue value = (SimpleValue ) mappedByProperty .getValue ();
585
585
final Iterator <Selectable > selectableValues = value .getColumnIterator ();
@@ -626,10 +626,9 @@ public MetadataBuildingContext getBuildingContext() {
626
626
}
627
627
);
628
628
629
- columnName = columnIdentifier .render ();
630
629
//one element was quoted so we quote
631
630
if ( isRefColumnQuoted || StringHelper .isQuoted ( mappedByTableName ) ) {
632
- columnName = StringHelper .quote ( columnName );
631
+ columnIdentifier = Identifier .quote ( columnIdentifier );
633
632
}
634
633
}
635
634
else if ( ownerSide ) {
@@ -647,7 +646,8 @@ else if ( getPropertyHolder().isEntity() ) {
647
646
else {
648
647
implicitNamingNature = ImplicitJoinColumnNameSource .Nature .ENTITY_COLLECTION ;
649
648
}
650
- Identifier columnNameIdentifier = getBuildingContext ().getBuildingOptions ().getImplicitNamingStrategy ().determineJoinColumnName (
649
+
650
+ columnIdentifier = getBuildingContext ().getBuildingOptions ().getImplicitNamingStrategy ().determineJoinColumnName (
651
651
new ImplicitJoinColumnNameSource () {
652
652
private final EntityNaming entityNaming = new EntityNaming () {
653
653
@ Override
@@ -705,19 +705,19 @@ public MetadataBuildingContext getBuildingContext() {
705
705
}
706
706
}
707
707
);
708
+
708
709
//one element was quoted so we quote
709
710
if ( isRefColumnQuoted || StringHelper .isQuoted ( logicalTableName ) ) {
710
- Identifier .quote ( columnNameIdentifier );
711
+ columnIdentifier = Identifier .quote ( columnIdentifier );
711
712
}
712
- columnName = columnNameIdentifier .render ();
713
713
}
714
714
else {
715
715
final Identifier logicalTableName = database .toIdentifier (
716
716
getBuildingContext ().getMetadataCollector ().getLogicalTableName ( referencedEntity .getTable () )
717
717
);
718
718
719
719
// is an intra-entity hierarchy table join so copy the name by default
720
- Identifier columnIdentifier = implicitNamingStrategy .determinePrimaryKeyJoinColumnName (
720
+ columnIdentifier = implicitNamingStrategy .determinePrimaryKeyJoinColumnName (
721
721
new ImplicitPrimaryKeyJoinColumnNameSource () {
722
722
@ Override
723
723
public MetadataBuildingContext getBuildingContext () {
@@ -739,11 +739,10 @@ public Identifier getReferencedPrimaryKeyColumnName() {
739
739
if ( !columnIdentifier .isQuoted () && ( isRefColumnQuoted || logicalTableName .isQuoted () ) ) {
740
740
columnIdentifier = Identifier .quote ( columnIdentifier );
741
741
}
742
-
743
- columnName = columnIdentifier .render ();
744
742
}
745
743
746
- return columnName ;
744
+ return physicalNamingStrategy .toPhysicalColumnName ( columnIdentifier , database .getJdbcEnvironment () )
745
+ .render ( database .getJdbcEnvironment ().getDialect () );
747
746
}
748
747
749
748
/**
0 commit comments