Skip to content

Commit 1ae44c0

Browse files
schaudergregturn
authored andcommitted
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.
1 parent b385f7f commit 1ae44c0

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

src/main/java/org/springframework/data/jdbc/core/DefaultDataAccessStrategy.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public <T> void deleteAll(Class<T> domainType) {
149149
}
150150

151151
@Override
152-
public void deleteAll(PropertyPath propertyPath) {
152+
public <T> void deleteAll(PropertyPath propertyPath) {
153153
operations.getJdbcOperations().update(sql(propertyPath.getOwningType().getType()).createDeleteAllSql(propertyPath));
154154
}
155155

@@ -192,17 +192,17 @@ public <T> Iterable<T> findAllById(Iterable<?> ids, Class<T> domainType) {
192192
return operations.query(findAllInListSql, parameter, getEntityRowMapper(domainType));
193193
}
194194

195+
@SuppressWarnings("unchecked")
195196
@Override
196-
public Iterable findAllByProperty(Object rootId, JdbcPersistentProperty property) {
197+
public <T> Iterable<T> findAllByProperty(Object rootId, JdbcPersistentProperty property) {
197198

198199
Class<?> actualType = property.getActualType();
199-
boolean isMap = property.getTypeInformation().isMap();
200200
String findAllByProperty = sql(actualType).getFindAllByProperty(property.getReverseColumnName(),
201201
property.getKeyColumn());
202202

203203
MapSqlParameterSource parameter = new MapSqlParameterSource(property.getReverseColumnName(), rootId);
204204

205-
return operations.query(findAllByProperty, parameter, isMap //
205+
return (Iterable<T>)operations.query(findAllByProperty, parameter, property.isQualified() //
206206
? getMapEntityRowMapper(property) //
207207
: getEntityRowMapper(actualType));
208208
}

src/main/java/org/springframework/data/jdbc/core/conversion/JdbcEntityWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private <T> DbAction singleSaveAction(T t, DbAction dependingOn) {
110110
private void insertReferencedEntities(PropertyAndValue propertyAndValue, AggregateChange aggregateChange, DbAction dependingOn) {
111111

112112
Insert<Object> insert;
113-
if (propertyAndValue.property.isMap()) {
113+
if (propertyAndValue.property.isQualified()) {
114114

115115
Entry<Object, Object> valueAsEntry = (Entry<Object, Object>) propertyAndValue.value;
116116
insert = DbAction.insert(valueAsEntry.getValue(), dependingOn);

src/main/java/org/springframework/data/jdbc/mapping/model/BasicJdbcPersistentProperty.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ public String getReverseColumnName() {
109109

110110
@Override
111111
public String getKeyColumn() {
112-
return isMap() ? context.getNamingStrategy().getKeyColumn(this) : null;
112+
return isQualified() ? context.getNamingStrategy().getKeyColumn(this) : null;
113+
}
114+
115+
@Override
116+
public boolean isQualified() {
117+
return isMap();
113118
}
114119

115120
private Class columnTypeIfEntity(Class type) {

src/main/java/org/springframework/data/jdbc/mapping/model/JdbcPersistentProperty.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ public interface JdbcPersistentProperty extends PersistentProperty<JdbcPersisten
4646
String getReverseColumnName();
4747

4848
String getKeyColumn();
49+
50+
/**
51+
* 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.
52+
*/
53+
boolean isQualified();
4954
}

0 commit comments

Comments
 (0)