Skip to content

Clarify and fix construction of foreign key column names #1324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0-1147-fk-naming-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data Relational Parent</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-data-jdbc-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0-1147-fk-naming-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions spring-data-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-data-jdbc</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0-1147-fk-naming-SNAPSHOT</version>

<name>Spring Data JDBC</name>
<description>Spring Data module for JDBC repositories.</description>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.0-1147-fk-naming-SNAPSHOT</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.convert.ConverterNotFoundException;
Expand All @@ -37,7 +38,6 @@
import org.springframework.data.mapping.Parameter;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.mapping.PreferredConstructor;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.DefaultSpELExpressionEvaluator;
import org.springframework.data.mapping.model.ParameterValueProvider;
Expand All @@ -52,7 +52,6 @@
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
import org.springframework.data.relational.core.sql.IdentifierProcessing;
import org.springframework.data.util.TypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -504,9 +503,7 @@ private boolean shouldCreateEmptyEmbeddedInstance(RelationalPersistentProperty p

private boolean hasInstanceValues(@Nullable Object idValue) {

RelationalPersistentEntity<?> persistentEntity = path.getLeafEntity();

Assert.state(persistentEntity != null, "Entity must not be null");
RelationalPersistentEntity<?> persistentEntity = path.getRequiredLeafEntity();

for (RelationalPersistentProperty embeddedProperty : persistentEntity) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ public Iterable<Object> findAllByPath(Identifier identifier,
Assert.notNull(propertyPath, "propertyPath must not be null");

PersistentPropertyPathExtension path = new PersistentPropertyPathExtension(context, propertyPath);

Class<?> actualType = path.getActualType();

String findAllByProperty = sql(actualType) //
.getFindAllByProperty(identifier, path.getQualifierColumn(), path.isOrdered());
.getFindAllByProperty(identifier, propertyPath);

RowMapper<?> rowMapper = path.isMap() ? this.getMapEntityRowMapper(path, identifier)
: this.getEntityRowMapper(path, identifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SqlContext {
SqlContext(RelationalPersistentEntity<?> entity) {

this.entity = entity;
this.table = Table.create(entity.getTableName());
this.table = Table.create(entity.getQualifiedTableName());
}

Column getIdColumn() {
Expand All @@ -55,7 +55,7 @@ Table getTable() {
Table getTable(PersistentPropertyPathExtension path) {

SqlIdentifier tableAlias = path.getTableAlias();
Table table = Table.create(path.getTableName());
Table table = Table.create(path.getQualifiedTableName());
return tableAlias == null ? table : table.as(tableAlias);
}

Expand Down
Loading