我正在尝试计算一些信息,并希望使用构造函数通过namedquery将它们插入到我的数据库中 这是代码:
@NamedQuery(name = PageEntity.FIND_ALL_PAGES_BY_TYPE, query = "SELECT DISTINCT new PageEntity
(e.id,e.backendId,e.name,e.pageType,e.updatedOn,e.updatedBy,e.mobileEnabled,e.desktopEnabled,e.mobileEnabledBy,e.desktopEnabledBy,e.mobileEnabledOn,e.desktopEnabledOn,
(SELECT COUNT(sc) FROM SectionContentEntity sc, PageSectionEntity ps WHERE ps.section.archived = false AND ps.page = e AND ps.section = sc.section),
(SELECT COUNT(sc) FROM SectionContentEntity sc, PageSectionEntity ps WHERE ps.section.archived = false AND ps.page = e AND ps.section = sc.section AND sc.desktopEnabled = false AND sc.mobileEnabled = false),
(SELECT COUNT(sc) FROM SectionContentEntity sc, PageSectionEntity ps WHERE ps.section.archived = false AND ps.page = e AND ps.section = sc.section AND sc.desktopEnabled = true),
(SELECT COUNT(sc) FROM SectionContentEntity sc, PageSectionEntity ps WHERE ps.section.archived = false AND ps.page = e AND ps.section = sc.section AND sc.mobileEnabled = true),
(SELECT COUNT(ps) FROM PageSectionEntity ps WHERE ps.section.archived = false AND ps.page = e),
(SELECT COUNT(ps) FROM PageSectionEntity ps WHERE ps.section.archived = false AND ps.page = e AND ps.mobileEnabled = true),
(SELECT COUNT(ps) FROM PageSectionEntity ps WHERE ps.section.archived = false AND ps.page = e AND ps.desktopEnabled = true)
) FROM PageEntity e WHERE e.archived=false AND e.removed=false AND e.pageType IN (:pageTypes) ORDER BY e.id"),
这是我得到的错误:
<pre>java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: The transaction has been marked rollback only because the bean encountered a non-application exception :org.apache.openjpa.persistence.ArgumentException : Your query on type "class com.moutawadia.seekeane.bu.bo.model.country.cms.page.PageSectionEntity" with filter "SELECT new PageEntity(e.backendId, (SELECT COUNT(ps) FROM PageSectionEntity ps WHERE ps.section.archived = false)) FROM PageEntity e WHERE e.archived=false AND e.removed=false AND e.pageType IN (:pageTypes) GROUP BY e.backendId" is invalid. Your select and having clauses must only include aggregates or values that also appear in your grouping clause. while invoking public com.moutawadia.fwk.jee.model.json.exchanges.ResponseJSON com.moutawadia.seekeane.bu.bo.services.entrypoint.country.cms.webstrategy.page.CountryWebPageWebService.findAllPagesByType(com.moutawadia.fwk.jee.model.json.exchanges.RequestJSON) with params [RequestJSON [action=null, executedByApp=, executedByUser=, executedByDevice=, backendId=, args=[MAIN]]].
org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:116)
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:324)
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:240)
org.apache.openejb.server.cxf.rs.CxfRsHttpListener.onMessage(CxfRsHttpListener.java:180)
org.apache.openejb.server.rest.RsServlet.service(RsServlet.java:53)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)