@@ -47,7 +47,7 @@ public class ElasticsearchPartQuery extends AbstractElasticsearchRepositoryQuery
4747
4848 public ElasticsearchPartQuery (ElasticsearchQueryMethod method , ElasticsearchOperations elasticsearchOperations ) {
4949 super (method , elasticsearchOperations );
50- this .tree = new PartTree (method .getName (), method .getEntityInformation ().getJavaType ());
50+ this .tree = new PartTree (method .getName (), method .getResultProcessor ().getReturnedType (). getDomainType ());
5151 this .mappingContext = elasticsearchOperations .getElasticsearchConverter ().getMappingContext ();
5252 }
5353
@@ -58,15 +58,17 @@ public Object execute(Object[] parameters) {
5858 CriteriaQuery query = createQuery (accessor );
5959 Assert .notNull (query , "unsupported query" );
6060
61+ Class <?> clazz = queryMethod .getResultProcessor ().getReturnedType ().getDomainType ();
62+
6163 if (tree .isDelete ()) {
6264 Object result = countOrGetDocumentsForDelete (query , accessor );
63- elasticsearchOperations .delete (query , queryMethod . getEntityInformation (). getJavaType () );
65+ elasticsearchOperations .delete (query , clazz );
6466 return result ;
6567 } else if (queryMethod .isPageQuery ()) {
6668 query .setPageable (accessor .getPageable ());
67- return elasticsearchOperations .queryForPage (query , queryMethod . getEntityInformation (). getJavaType () );
69+ return elasticsearchOperations .queryForPage (query , clazz );
6870 } else if (queryMethod .isStreamQuery ()) {
69- Class <?> entityType = queryMethod . getEntityInformation (). getJavaType () ;
71+ Class <?> entityType = clazz ;
7072 if (accessor .getPageable ().isUnpaged ()) {
7173 query .setPageable (PageRequest .of (0 , DEFAULT_STREAM_BATCH_SIZE ));
7274 } else {
@@ -78,18 +80,18 @@ public Object execute(Object[] parameters) {
7880
7981 if (accessor .getPageable ().isUnpaged ()) {
8082
81- int itemCount = (int ) elasticsearchOperations .count (query , queryMethod . getEntityInformation (). getJavaType () );
83+ int itemCount = (int ) elasticsearchOperations .count (query , clazz );
8284 query .setPageable (PageRequest .of (0 , Math .max (1 , itemCount )));
8385 } else {
8486 query .setPageable (accessor .getPageable ());
8587 }
8688
87- return elasticsearchOperations .queryForList (query , queryMethod . getEntityInformation (). getJavaType () );
89+ return elasticsearchOperations .queryForList (query , clazz );
8890 } else if (tree .isCountProjection ()) {
89- return elasticsearchOperations .count (query , queryMethod . getEntityInformation (). getJavaType () );
91+ return elasticsearchOperations .count (query , clazz );
9092 }
9193
92- return elasticsearchOperations .queryForObject (query , queryMethod . getEntityInformation (). getJavaType () );
94+ return elasticsearchOperations .queryForObject (query , clazz );
9395 }
9496
9597 private Object countOrGetDocumentsForDelete (CriteriaQuery query , ParametersParameterAccessor accessor ) {
0 commit comments