DATAJDBC-464 - No longer require MappingContext to create BasicRelationalPersistentProperty.

We now no longer require MappingContext to create BasicRelationalPersistentProperty and BasicJdbcPersistentProperty.
We require only the NamingStrategy so we're just passing that one instead of the entire context.

Original pull request: #186.
This commit is contained in:
Mark Paluch
2020-01-31 10:32:36 +01:00
parent b29a789846
commit f1d2d78dc8
4 changed files with 56 additions and 21 deletions

View File

@@ -15,15 +15,17 @@
*/
package org.springframework.data.jdbc.core.mapping;
import org.springframework.data.jdbc.support.JdbcUtil;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.model.Property;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.data.relational.core.mapping.BasicRelationalPersistentProperty;
import org.springframework.data.relational.core.mapping.NamingStrategy;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
/**
* Extension to {@link BasicRelationalPersistentProperty}.
*
* @author Mark Paluch
*/
public class BasicJdbcPersistentProperty extends BasicRelationalPersistentProperty {
@@ -35,12 +37,29 @@ public class BasicJdbcPersistentProperty extends BasicRelationalPersistentProper
* @param owner must not be {@literal null}.
* @param simpleTypeHolder must not be {@literal null}.
* @param context must not be {@literal null}
* @deprecated since 2.0, use
* {@link #BasicJdbcPersistentProperty(Property, PersistentEntity, SimpleTypeHolder, NamingStrategy)}.
*/
@Deprecated
public BasicJdbcPersistentProperty(Property property, PersistentEntity<?, RelationalPersistentProperty> owner,
SimpleTypeHolder simpleTypeHolder, RelationalMappingContext context) {
super(property, owner, simpleTypeHolder, context);
}
/**
* Creates a new {@link BasicJdbcPersistentProperty}.
*
* @param property must not be {@literal null}.
* @param owner must not be {@literal null}.
* @param simpleTypeHolder must not be {@literal null}.
* @param namingStrategy must not be {@literal null}
* @since 2.0
*/
public BasicJdbcPersistentProperty(Property property, PersistentEntity<?, RelationalPersistentProperty> owner,
SimpleTypeHolder simpleTypeHolder, NamingStrategy namingStrategy) {
super(property, owner, simpleTypeHolder, namingStrategy);
}
@Override
public boolean isReference() {
return AggregateReference.class.isAssignableFrom(getRawType());

View File

@@ -85,7 +85,7 @@ public class JdbcMappingContext extends RelationalMappingContext {
@Override
protected RelationalPersistentProperty createPersistentProperty(Property property,
RelationalPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
return new BasicJdbcPersistentProperty(property, owner, simpleTypeHolder, this);
return new BasicJdbcPersistentProperty(property, owner, simpleTypeHolder, this.getNamingStrategy());
}
@Override