@@ -426,7 +426,7 @@ private Identifier columnIdentifier(
426
426
ImplicitNamingStrategy implicitNamingStrategy ,
427
427
InFlightMetadataCollector collector ,
428
428
Database database ) {
429
- boolean isRefColumnQuoted = isQuoted ( logicalReferencedColumn );
429
+ final boolean isRefColumnQuoted = isQuoted ( logicalReferencedColumn );
430
430
431
431
if ( isMappedBySide () ) {
432
432
// NOTE: An @ElementCollection can't be mappedBy, but the client code
@@ -439,17 +439,10 @@ private Identifier columnIdentifier(
439
439
}
440
440
else if ( isOwnerSide () ) {
441
441
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 )
444
444
);
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 ) );
453
446
}
454
447
else {
455
448
final Identifier logicalTableName = database .toIdentifier (
@@ -478,9 +471,23 @@ public Identifier getReferencedPrimaryKeyColumnName() {
478
471
}
479
472
}
480
473
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
+
481
487
private static Identifier quoteIfNecessary (
482
488
boolean isRefColumnQuoted , Identifier logicalTableName , Identifier columnIdentifier ) {
483
- return !columnIdentifier .isQuoted () && ( isRefColumnQuoted || logicalTableName .isQuoted () )
489
+ return !columnIdentifier .isQuoted ()
490
+ && ( isRefColumnQuoted || logicalTableName .isQuoted () )
484
491
? Identifier .quote ( columnIdentifier )
485
492
: columnIdentifier ;
486
493
}
@@ -591,8 +598,9 @@ public Identifier getReferencedColumnName() {
591
598
return null ;
592
599
}
593
600
594
- final Property mappedByProperty = collector .getEntityBinding ( getMappedByEntityName () )
595
- .getProperty ( getMappedByPropertyName () );
601
+ final Property mappedByProperty =
602
+ collector .getEntityBinding ( getMappedByEntityName () )
603
+ .getProperty ( getMappedByPropertyName () );
596
604
final SimpleValue value = (SimpleValue ) mappedByProperty .getValue ();
597
605
if ( value .getSelectables ().isEmpty () ) {
598
606
throw new AnnotationException (
0 commit comments