HHH-10863 Be consistent in the parameter passed to
ImplicitNamingStrategy#determineBasicColumnName
When dealing with an element collection (say items.name),
ImplicitNamingStrategy#determineBasicColumnName is sometimes called
with items.collection&&element.name and sometimes with items.name.
This is due to HHH-6005 which removes the "collection&&element."
part before calling determineBasicColumnName.
With this patch, we only remove the "collection&&element." part before
calling the physical naming strategy, thus allowing us to be consistent
in the way we call ImplicitNamingStrategy#determineBasicColumnName.
(cherry picked from commit 9fd61a10db
)
This commit is contained in:
parent
8e8be9aeb4
commit
8e64e3ac93
|
@ -269,13 +269,9 @@ public class Ejb3Column {
|
|||
if ( applyNamingStrategy ) {
|
||||
if ( StringHelper.isEmpty( columnName ) ) {
|
||||
if ( propertyName != null ) {
|
||||
/// HHH-6005 magic
|
||||
if ( propertyName.contains( ".collection&&element." ) ) {
|
||||
propertyName = propertyName.replace( "collection&&element.", "" );
|
||||
}
|
||||
final AttributePath attributePath = AttributePath.parse( propertyName );
|
||||
|
||||
final Identifier implicitName = normalizer.normalizeIdentifierQuoting(
|
||||
Identifier implicitName = normalizer.normalizeIdentifierQuoting(
|
||||
implicitNamingStrategy.determineBasicColumnName(
|
||||
new ImplicitBasicColumnNameSource() {
|
||||
@Override
|
||||
|
@ -299,6 +295,12 @@ public class Ejb3Column {
|
|||
)
|
||||
);
|
||||
|
||||
// HHH-6005 magic
|
||||
if ( implicitName.getText().contains( "_collection&&element_" ) ) {
|
||||
implicitName = Identifier.toIdentifier( implicitName.getText().replace( "_collection&&element_", "_" ),
|
||||
implicitName.isQuoted() );
|
||||
}
|
||||
|
||||
final Identifier physicalName = physicalNamingStrategy.toPhysicalColumnName( implicitName, database.getJdbcEnvironment() );
|
||||
mappingColumn.setName( physicalName.render( database.getDialect() ) );
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ComponentNamingStrategyTest extends BaseUnitTestCase {
|
|||
SimpleValue elementValue = assertTyping( SimpleValue.class, value.getElement() );
|
||||
assertEquals( 1, elementValue.getColumnSpan() );
|
||||
Column column = assertTyping( Column.class, elementValue.getColumnIterator().next() );
|
||||
assertEquals( column.getName(), "items_name" );
|
||||
assertEquals( "items_name", column.getName() );
|
||||
}
|
||||
finally {
|
||||
StandardServiceRegistryBuilder.destroy( ssr );
|
||||
|
|
Loading…
Reference in New Issue