The back reference generation is now configurable.
The default version is the behavior that existed so far: The back reference is the table name as generated by the `NamingStrategy` without taking `@Table` annotations into account. The new alternative is to take `@Table` into account. The behavior can be configured by setting the `foreignKeyNaming` property on the `RelationalMappingContext`. Closes #1161 Closes #1147 Original pull request: #1324.
This commit is contained in:
committed by
Mark Paluch
parent
15796b88fe
commit
40446f9ca9
@@ -277,7 +277,7 @@ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStra
|
||||
|
||||
@Override
|
||||
public SqlIdentifier getTableName(Class<?> type) {
|
||||
return getRequiredPersistentEntity(type).getTableName();
|
||||
return getRequiredPersistentEntity(type).getFullTableName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -465,7 +465,7 @@ public class R2dbcEntityTemplate implements R2dbcEntityOperations, BeanFactoryAw
|
||||
|
||||
Assert.notNull(entity, "Entity must not be null");
|
||||
|
||||
return doInsert(entity, getRequiredEntity(entity).getTableName());
|
||||
return doInsert(entity, getRequiredEntity(entity).getFullTableName());
|
||||
}
|
||||
|
||||
<T> Mono<T> doInsert(T entity, SqlIdentifier tableName) {
|
||||
@@ -564,7 +564,7 @@ public class R2dbcEntityTemplate implements R2dbcEntityOperations, BeanFactoryAw
|
||||
|
||||
Assert.notNull(entity, "Entity must not be null");
|
||||
|
||||
return doUpdate(entity, getRequiredEntity(entity).getTableName());
|
||||
return doUpdate(entity, getRequiredEntity(entity).getFullTableName());
|
||||
}
|
||||
|
||||
private <T> Mono<T> doUpdate(T entity, SqlIdentifier tableName) {
|
||||
@@ -644,13 +644,13 @@ public class R2dbcEntityTemplate implements R2dbcEntityOperations, BeanFactoryAw
|
||||
private <T> String formatOptimisticLockingExceptionMessage(T entity, RelationalPersistentEntity<T> persistentEntity) {
|
||||
|
||||
return String.format("Failed to update table [%s]; Version does not match for row with Id [%s]",
|
||||
persistentEntity.getTableName(), persistentEntity.getIdentifierAccessor(entity).getIdentifier());
|
||||
persistentEntity.getFullTableName(), persistentEntity.getIdentifierAccessor(entity).getIdentifier());
|
||||
}
|
||||
|
||||
private <T> String formatTransientEntityExceptionMessage(T entity, RelationalPersistentEntity<T> persistentEntity) {
|
||||
|
||||
return String.format("Failed to update table [%s]; Row with Id [%s] does not exist",
|
||||
persistentEntity.getTableName(), persistentEntity.getIdentifierAccessor(entity).getIdentifier());
|
||||
persistentEntity.getFullTableName(), persistentEntity.getIdentifierAccessor(entity).getIdentifier());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -744,14 +744,14 @@ public class R2dbcEntityTemplate implements R2dbcEntityOperations, BeanFactoryAw
|
||||
}
|
||||
|
||||
SqlIdentifier getTableName(Class<?> entityClass) {
|
||||
return getRequiredEntity(entityClass).getTableName();
|
||||
return getRequiredEntity(entityClass).getFullTableName();
|
||||
}
|
||||
|
||||
SqlIdentifier getTableNameOrEmpty(Class<?> entityClass) {
|
||||
|
||||
RelationalPersistentEntity<?> entity = this.mappingContext.getPersistentEntity(entityClass);
|
||||
|
||||
return entity != null ? entity.getTableName() : SqlIdentifier.EMPTY;
|
||||
return entity != null ? entity.getFullTableName() : SqlIdentifier.EMPTY;
|
||||
}
|
||||
|
||||
private RelationalPersistentEntity<?> getRequiredEntity(Class<?> entityClass) {
|
||||
|
||||
Reference in New Issue
Block a user