Skip to content

Commit 0373a58

Browse files
committed
DATAJDBC-263 - Polishing.
Improved formatting, added author tags and issue comments. Changed "entity" to "aggregate" in test names to make it more precise. Original pull request: #94.
1 parent 11d535e commit 0373a58

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

src/main/java/org/springframework/data/jdbc/repository/support/JdbcQueryLookupStrategy.java

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* @author Kazuki Shimizu
4242
* @author Oliver Gierke
4343
* @author Mark Paluch
44+
* @author Maciej Walkowiak
4445
*/
4546
class JdbcQueryLookupStrategy implements QueryLookupStrategy {
4647

src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryQuery.java

+3
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,14 @@ public Object execute(Object[] objects) {
9999
}
100100

101101
if (queryMethod.isCollectionQuery() || queryMethod.isStreamQuery()) {
102+
102103
List<?> result = operations.query(query, parameters, rowMapper);
103104
publishAfterLoad(result);
104105
return result;
105106
}
106107

107108
try {
109+
108110
Object result = operations.queryForObject(query, parameters, rowMapper);
109111
publishAfterLoad(result);
110112
return result;
@@ -166,6 +168,7 @@ private <T> void publishAfterLoad(Iterable<T> all) {
166168
private <T> void publishAfterLoad(@Nullable T entity) {
167169

168170
if (entity != null && context.hasPersistentEntityFor(entity.getClass())) {
171+
169172
RelationalPersistentEntity<?> e = context.getRequiredPersistentEntity(entity.getClass());
170173
Object identifier = e.getIdentifierAccessor(entity)
171174
.getIdentifier();

src/test/java/org/springframework/data/jdbc/repository/support/JdbcQueryLookupStrategyUnitTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* @author Jens Schauder
4848
* @author Oliver Gierke
4949
* @author Mark Paluch
50+
* @author Maciej Walkowiak
5051
*/
5152
public class JdbcQueryLookupStrategyUnitTests {
5253

src/test/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryQueryUnitTests.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
*
3939
* @author Jens Schauder
4040
* @author Oliver Gierke
41+
* @author Maciej Walkowiak
4142
*/
4243
public class JdbcRepositoryQueryUnitTests {
4344

@@ -108,8 +109,8 @@ public void customRowMapperIsUsedWhenSpecified() {
108109
.queryForObject(anyString(), any(SqlParameterSource.class), isA(CustomRowMapper.class));
109110
}
110111

111-
@Test
112-
public void publishesSingleEventWhenQueryReturnsSingleElement() {
112+
@Test // DATAJDBC-263
113+
public void publishesSingleEventWhenQueryReturnsSingleAggregate() {
113114

114115
doReturn("some sql statement").when(queryMethod).getAnnotatedQuery();
115116
doReturn(false).when(queryMethod).isCollectionQuery();
@@ -122,8 +123,8 @@ public void publishesSingleEventWhenQueryReturnsSingleElement() {
122123
verify(publisher).publishEvent(any(AfterLoadEvent.class));
123124
}
124125

125-
@Test
126-
public void publishesAsManyEventsAsReturnedEntities() {
126+
@Test // DATAJDBC-263
127+
public void publishesAsManyEventsAsReturnedAggregates() {
127128

128129
doReturn("some sql statement").when(queryMethod).getAnnotatedQuery();
129130
doReturn(true).when(queryMethod).isCollectionQuery();

0 commit comments

Comments
 (0)