DATAJDBC-218 - The Column annotation affects the back reference too.

Also:
Added documentation for the new behavior.
Made the value of the column annotation optional by providing a default.

Original pull request: #83.
This commit is contained in:
Jens Schauder
2018-09-18 14:34:05 +02:00
parent 335a7cbe65
commit 08ee846e71
4 changed files with 12 additions and 5 deletions

View File

@@ -73,7 +73,13 @@ class BasicRelationalPersistentProperty extends AnnotationBasedPersistentPropert
Assert.notNull(context, "context must not be null.");
this.context = context;
this.columnName = Lazy.of(() -> Optional.ofNullable(findAnnotation(Column.class)).map(Column::value));
this.columnName = Lazy.of(() -> Optional.ofNullable( //
findAnnotation(Column.class)) //
.map(Column::value) //
.filter(StringUtils::hasText) //
);
this.keyColumnName = Lazy.of(() -> Optional.ofNullable( //
findAnnotation(Column.class)) //
.map(Column::keyColumn) //
@@ -120,7 +126,7 @@ class BasicRelationalPersistentProperty extends AnnotationBasedPersistentPropert
@Override
public String getReverseColumnName() {
return context.getNamingStrategy().getReverseColumnName(this);
return columnName.get().orElseGet(() -> context.getNamingStrategy().getReverseColumnName(this));
}
@Override

View File

@@ -35,7 +35,7 @@ public @interface Column {
/**
* The mapping column name.
*/
String value();
String value() default "";
/**
* The column name for key columns of List or Map collections.