<queries xmlns="http://jmix.io/schema/rest/queries">
<query name="usersDto" entity="User" fetchPlan="user-fetch-plan">
<jpql><![CDATA[select e from User e]]></jpql>
</query>
</queries>
Works fine
Try to map this via JPQL DTO mapping:
<queries xmlns="http://jmix.io/schema/rest/queries">
<query name="usersDto" entity="User" fetchPlan="user-fetch-plan">
<jpql><![CDATA[select new com.company.untitled3.entity.UserDTO(e.id, e.username, e.firstName, e.lastName) from User e]]></jpql>
</query>
</queries>
-> Produces error
io.jmix.core.DevelopmentException: DataManager cannot execute query for single attributes
at io.jmix.eclipselink.impl.JpaDataStore.executeQuery(JpaDataStore.java:607) ~[jmix-eclipselink-2.4.1.jar:na]
at io.jmix.eclipselink.impl.JpaDataStore.loadAll(JpaDataStore.java:169) ~[jmix-eclipselink-2.4.1.jar:na]
at io.jmix.core.datastore.AbstractDataStore.loadList(AbstractDataStore.java:129) ~[jmix-core-2.4.1.jar:na]
at io.jmix.core.impl.UnconstrainedDataManagerImpl.loadList(UnconstrainedDataManagerImpl.java:112) ~[jmix-core-2.4.1.jar:na]
at io.jmix.rest.impl.service.QueriesControllerManager._executeQuery(QueriesControllerManager.java:131) ~[jmix-rest-2.4.1.jar:na]
at io.jmix.rest.impl.service.QueriesControllerManager.executeQueryGet(QueriesControllerManager.java:92) ~[jmix-rest-2.4.1.jar:na]
at io.jmix.rest.impl.controller.QueriesController.executeQueryGet(QueriesController.java:55) ~[jmix-rest-2.4.1.jar:na]
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:255) ~[spring-web-6.1.14.jar:6.1.14]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:188) ~[spring-web-6.1.14.jar:6.1.14]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118) ~[spring-webmvc-6.1.14.jar:6.1.14]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:926) ~[spring-webmvc-6.1.14.jar:6.1.14]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:831) ~[spring-webmvc-6.1.14.jar:6.1.14]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-6.1.14.jar:6.1.14]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089) ~[spring-webmvc-6.1.14.jar:6.1.14]
Environment
Jmix version: 2.4
Bug Description
Try do this:
Works fine
-> Produces error
Source issue from forum