Skip to content

Commit

Permalink
HHH-8468 - @joincolumn(table = "...") doesn't use NamingStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
s.vasilyev authored and brmeyer committed Sep 5, 2013
1 parent 5e1102b commit e22bd63
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -256,7 +256,7 @@ private static Ejb3JoinColumn buildJoinColumn(
);
}
Ejb3JoinColumn joinColumn = new Ejb3JoinColumn();
joinColumn.setJoinAnnotation( ann, null );
joinColumn.setJoinAnnotation( ann, null, mappings );
if ( StringHelper.isEmpty( joinColumn.getLogicalColumnName() )
&& ! StringHelper.isEmpty( suffixForDefaultColumnName ) ) {
joinColumn.setLogicalColumnName( propertyName + suffixForDefaultColumnName );
Expand Down Expand Up @@ -293,20 +293,24 @@ private static Ejb3JoinColumn buildJoinColumn(


// TODO default name still useful in association table
public void setJoinAnnotation(JoinColumn annJoin, String defaultName) {
public void setJoinAnnotation(JoinColumn annJoin, String defaultName, Mappings mappings) {
if ( annJoin == null ) {
setImplicit( true );
}
else {
setImplicit( false );
final ObjectNameNormalizer nameNormalizer = mappings.getObjectNameNormalizer();
if ( !BinderHelper.isEmptyAnnotationValue( annJoin.columnDefinition() ) ) setSqlType( annJoin.columnDefinition() );
if ( !BinderHelper.isEmptyAnnotationValue( annJoin.name() ) ) setLogicalColumnName( annJoin.name() );
setNullable( annJoin.nullable() );
setUnique( annJoin.unique() );
setInsertable( annJoin.insertable() );
setUpdatable( annJoin.updatable() );
setReferencedColumn( annJoin.referencedColumnName() );
setSecondaryTableName( annJoin.table() );

final String tableName = !BinderHelper.isEmptyAnnotationValue( annJoin.table() )
? nameNormalizer.normalizeIdentifierQuoting( mappings.getNamingStrategy().tableName( annJoin.table() ) ) : "";
setSecondaryTableName( tableName );
}
}

Expand Down Expand Up @@ -675,7 +679,7 @@ public static Ejb3JoinColumn[] buildJoinTableJoinColumns(
currentJoinColumn.setMappings( mappings );
currentJoinColumn.setPropertyName( BinderHelper.getRelativePath( propertyHolder, propertyName ) );
currentJoinColumn.setMappedBy( mappedBy );
currentJoinColumn.setJoinAnnotation( annJoin, propertyName );
currentJoinColumn.setJoinAnnotation( annJoin, propertyName, mappings );
currentJoinColumn.setNullable( false ); //I break the spec, but it's for good
//done after the annotation to override it
currentJoinColumn.bind();
Expand Down

0 comments on commit e22bd63

Please sign in to comment.