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.
This commit is contained in:
@@ -41,6 +41,7 @@ import org.springframework.util.Assert;
|
||||
* @author Kazuki Shimizu
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Maciej Walkowiak
|
||||
*/
|
||||
class JdbcQueryLookupStrategy implements QueryLookupStrategy {
|
||||
|
||||
|
||||
@@ -99,12 +99,14 @@ class JdbcRepositoryQuery implements RepositoryQuery {
|
||||
}
|
||||
|
||||
if (queryMethod.isCollectionQuery() || queryMethod.isStreamQuery()) {
|
||||
|
||||
List<?> result = operations.query(query, parameters, rowMapper);
|
||||
publishAfterLoad(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Object result = operations.queryForObject(query, parameters, rowMapper);
|
||||
publishAfterLoad(result);
|
||||
return result;
|
||||
@@ -166,6 +168,7 @@ class JdbcRepositoryQuery implements RepositoryQuery {
|
||||
private <T> void publishAfterLoad(@Nullable T entity) {
|
||||
|
||||
if (entity != null && context.hasPersistentEntityFor(entity.getClass())) {
|
||||
|
||||
RelationalPersistentEntity<?> e = context.getRequiredPersistentEntity(entity.getClass());
|
||||
Object identifier = e.getIdentifierAccessor(entity)
|
||||
.getIdentifier();
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
* @author Jens Schauder
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Maciej Walkowiak
|
||||
*/
|
||||
public class JdbcQueryLookupStrategyUnitTests {
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @author Oliver Gierke
|
||||
* @author Maciej Walkowiak
|
||||
*/
|
||||
public class JdbcRepositoryQueryUnitTests {
|
||||
|
||||
@@ -108,8 +109,8 @@ public class JdbcRepositoryQueryUnitTests {
|
||||
.queryForObject(anyString(), any(SqlParameterSource.class), isA(CustomRowMapper.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publishesSingleEventWhenQueryReturnsSingleElement() {
|
||||
@Test // DATAJDBC-263
|
||||
public void publishesSingleEventWhenQueryReturnsSingleAggregate() {
|
||||
|
||||
doReturn("some sql statement").when(queryMethod).getAnnotatedQuery();
|
||||
doReturn(false).when(queryMethod).isCollectionQuery();
|
||||
@@ -122,8 +123,8 @@ public class JdbcRepositoryQueryUnitTests {
|
||||
verify(publisher).publishEvent(any(AfterLoadEvent.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publishesAsManyEventsAsReturnedEntities() {
|
||||
@Test // DATAJDBC-263
|
||||
public void publishesAsManyEventsAsReturnedAggregates() {
|
||||
|
||||
doReturn("some sql statement").when(queryMethod).getAnnotatedQuery();
|
||||
doReturn(true).when(queryMethod).isCollectionQuery();
|
||||
|
||||
Reference in New Issue
Block a user