File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
src/main/java/org/springframework/data/jdbc/mapping/model Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 1515 */
1616package org .springframework .data .jdbc .mapping .model ;
1717
18+ import org .springframework .core .annotation .AnnotatedElementUtils ;
19+
20+ import java .util .Optional ;
21+
1822/**
1923 * Interface and default implementation of a naming strategy. Defaults to no schema, table name based on {@link Class}
2024 * and column name based on {@link JdbcPersistentProperty}.
@@ -45,17 +49,23 @@ default String getSchema() {
4549 }
4650
4751 /**
48- * Look up the {@link Class}'s simple name.
52+ * Look up the {@link Class}'s simple name or {@link Table#value()} .
4953 */
5054 default String getTableName (Class <?> type ) {
51- return type .getSimpleName ();
55+ Table table = AnnotatedElementUtils .findMergedAnnotation (type , Table .class );
56+ return Optional .ofNullable (table )//
57+ .map (Table ::value )//
58+ .orElse (type .getSimpleName ());
5259 }
5360
5461 /**
55- * Look up the {@link JdbcPersistentProperty}'s name.
62+ * Look up the {@link JdbcPersistentProperty}'s name or {@link Column#value()} .
5663 */
5764 default String getColumnName (JdbcPersistentProperty property ) {
58- return property .getName ();
65+ Column column = property .findAnnotation (Column .class );
66+ return Optional .ofNullable (column )//
67+ .map (Column ::value )//
68+ .orElse (property .getName ());
5969 }
6070
6171 default String getQualifiedTableName (Class <?> type ) {
You can’t perform that action at this time.
0 commit comments