DATAJDBC-131 - Polishing after review.
Put generics back in and added @SupressWarnings where this caused warnings. Extracted the test “isMap” into a “isQualified” method on the property.
This commit is contained in:
committed by
Greg Turnquist
parent
b385f7f24f
commit
1ae44c0006
@@ -149,7 +149,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(PropertyPath propertyPath) {
|
||||
public <T> void deleteAll(PropertyPath propertyPath) {
|
||||
operations.getJdbcOperations().update(sql(propertyPath.getOwningType().getType()).createDeleteAllSql(propertyPath));
|
||||
}
|
||||
|
||||
@@ -192,17 +192,17 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
return operations.query(findAllInListSql, parameter, getEntityRowMapper(domainType));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Iterable findAllByProperty(Object rootId, JdbcPersistentProperty property) {
|
||||
public <T> Iterable<T> findAllByProperty(Object rootId, JdbcPersistentProperty property) {
|
||||
|
||||
Class<?> actualType = property.getActualType();
|
||||
boolean isMap = property.getTypeInformation().isMap();
|
||||
String findAllByProperty = sql(actualType).getFindAllByProperty(property.getReverseColumnName(),
|
||||
property.getKeyColumn());
|
||||
|
||||
MapSqlParameterSource parameter = new MapSqlParameterSource(property.getReverseColumnName(), rootId);
|
||||
|
||||
return operations.query(findAllByProperty, parameter, isMap //
|
||||
return (Iterable<T>)operations.query(findAllByProperty, parameter, property.isQualified() //
|
||||
? getMapEntityRowMapper(property) //
|
||||
: getEntityRowMapper(actualType));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class JdbcEntityWriter extends JdbcEntityWriterSupport {
|
||||
private void insertReferencedEntities(PropertyAndValue propertyAndValue, AggregateChange aggregateChange, DbAction dependingOn) {
|
||||
|
||||
Insert<Object> insert;
|
||||
if (propertyAndValue.property.isMap()) {
|
||||
if (propertyAndValue.property.isQualified()) {
|
||||
|
||||
Entry<Object, Object> valueAsEntry = (Entry<Object, Object>) propertyAndValue.value;
|
||||
insert = DbAction.insert(valueAsEntry.getValue(), dependingOn);
|
||||
|
||||
@@ -109,7 +109,12 @@ public class BasicJdbcPersistentProperty extends AnnotationBasedPersistentProper
|
||||
|
||||
@Override
|
||||
public String getKeyColumn() {
|
||||
return isMap() ? context.getNamingStrategy().getKeyColumn(this) : null;
|
||||
return isQualified() ? context.getNamingStrategy().getKeyColumn(this) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQualified() {
|
||||
return isMap();
|
||||
}
|
||||
|
||||
private Class columnTypeIfEntity(Class type) {
|
||||
|
||||
@@ -46,4 +46,9 @@ public interface JdbcPersistentProperty extends PersistentProperty<JdbcPersisten
|
||||
String getReverseColumnName();
|
||||
|
||||
String getKeyColumn();
|
||||
|
||||
/**
|
||||
* Returns if this property is a qualified property, i.e. a property referencing multiple elements that can get picked by a key or an index.
|
||||
*/
|
||||
boolean isQualified();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user