You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Wei Zhang (JIRA)" <ji...@apache.org> on 2017/09/05 01:54:00 UTC

[jira] [Created] (OFBIZ-9676) Error of GROUP BY in SQL

Wei Zhang created OFBIZ-9676:
--------------------------------

             Summary: Error of GROUP BY in SQL
                 Key: OFBIZ-9676
                 URL: https://issues.apache.org/jira/browse/OFBIZ-9676
             Project: OFBiz
          Issue Type: Bug
          Components: framework
    Affects Versions: Trunk
            Reporter: Wei Zhang


To reproduce this error:

1. Create a view entity
{code:borderStyle=solid}
    <view-entity entity-name="ExampleTypeView" package-name="org.apache.ofbiz.example.example">
        <member-entity entity-alias="EX" entity-name="Example"/>
        <alias entity-alias="EX" name="exampleId" field="exampleId" />
        <alias entity-alias="EX" name="exampleTypeId" group-by="true"/>
    </view-entity>
{code}

2. Find the view entity in groovy
{code:borderStyle=solid}
    EntityQuery.use(delegator).from("ExampleTypeView").queryList()

{code}

3. An error will occur as below

2017-08-29 10:27:09,990 |jsse-nio-8443-exec-3 |GenericDelegator              |E| Failure in findByCondition operation for entity [ExampleTypeView]: org.apache.ofbiz.entity.GenericDataSourceException: SQL Exception while executing the following:SELECT EX.EXAMPLE_ID, EX.EXAMPLE_TYPE_ID FROM public.EXAMPLE EX GROUP BY EX.EXAMPLE_TYPE_ID (ERROR: column "ex.example_id" must appear in the GROUP BY clause or be used in an aggregate function
  Position: 8). Rolling back transaction.
org.apache.ofbiz.entity.GenericDataSourceException: SQL Exception while executing the following:SELECT EX.EXAMPLE_ID, EX.EXAMPLE_TYPE_ID FROM public.EXAMPLE EX GROUP BY EX.EXAMPLE_TYPE_ID (ERROR: column "ex.example_id" must appear in the GROUP BY clause or be used in an aggregate function
  Position: 8)
        at org.apache.ofbiz.entity.jdbc.SQLProcessor.executeQuery(SQLProcessor.java:446) ~[ofbiz.jar:?]
        at org.apache.ofbiz.entity.datasource.GenericDAO.selectListIteratorByCondition(GenericDAO.java:869) ~[ofbiz.jar:?]
        at org.apache.ofbiz.entity.datasource.GenericHelperDAO.findListIteratorByCondition(GenericHelperDAO.java:141) ~[ofbiz.jar:?]
        at org.apache.ofbiz.entity.GenericDelegator.find(GenericDelegator.java:1552) ~[ofbiz.jar:?]
        at org.apache.ofbiz.entity.GenericDelegator.findList(GenericDelegator.java:1586) [ofbiz.jar:?]
        at org.apache.ofbiz.entity.util.EntityQuery.query(EntityQuery.java:451) [ofbiz.jar:?]
        at org.apache.ofbiz.entity.util.EntityQuery.queryList(EntityQuery.java:381) [ofbiz.jar:?]
        at org.apache.ofbiz.entity.util.EntityQuery$queryList$1.call(Unknown Source) [ofbiz.jar:?]
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) [groovy-all-2.4.12.jar:2.4.12]
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) [groovy-all-2.4.12.jar:2.4.12]
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) [groovy-all-2.4.12.jar:2.4.12]
        at uk.co.robertheath.mobile.FooServices.getFoo(FooServices.groovy:31) [script:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]

Kind Regards,

Wei




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)