DATACMNS-171 - Let JpaQueryMethod new method of QueryMethod.
Drop custom method to determine whether a query method returns an entity and rather use the newly introduced method in Spring Data Commons' QueryMethod.
This commit is contained in:
@@ -227,15 +227,6 @@ public class JpaQueryMethod extends QueryMethod {
|
||||
return (Boolean) AnnotationUtils.getValue(method.getAnnotation(Modifying.class), "clearAutomatically");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the query method will actually return entities.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isQueryMethodForEntity() {
|
||||
return getDomainClass().isAssignableFrom(getReturnedObjectType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Query} annotation's attribute casted to the given type or default value if no annotation
|
||||
* available.
|
||||
|
||||
@@ -90,8 +90,8 @@ final class SimpleJpaQuery extends AbstractJpaQuery {
|
||||
Query query = null;
|
||||
|
||||
if (method.isNativeQuery()) {
|
||||
query = method.isQueryMethodForEntity() ? em.createNativeQuery(sortedQueryString, method.getReturnedObjectType())
|
||||
: em.createNativeQuery(sortedQueryString);
|
||||
query = method.isQueryForEntity() ? em.createNativeQuery(sortedQueryString, method.getReturnedObjectType()) : em
|
||||
.createNativeQuery(sortedQueryString);
|
||||
} else {
|
||||
query = em.createQuery(sortedQueryString);
|
||||
}
|
||||
|
||||
@@ -289,8 +289,8 @@ public class JpaQueryMethodUnitTests {
|
||||
when(metadata.getReturnedDomainClass(findsProjections)).thenReturn((Class) Integer.class);
|
||||
when(metadata.getReturnedDomainClass(findsProjection)).thenReturn((Class) Integer.class);
|
||||
|
||||
assertThat(new JpaQueryMethod(findsProjections, metadata, extractor).isQueryMethodForEntity(), is(false));
|
||||
assertThat(new JpaQueryMethod(findsProjection, metadata, extractor).isQueryMethodForEntity(), is(false));
|
||||
assertThat(new JpaQueryMethod(findsProjections, metadata, extractor).isQueryForEntity(), is(false));
|
||||
assertThat(new JpaQueryMethod(findsProjection, metadata, extractor).isQueryForEntity(), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user