[seam-issues] [JBoss JIRA] Commented: (JBSEAM-4694) Query class does not handle distinct query properly

Michael K (JIRA) jira-events at lists.jboss.org
Mon Aug 1 11:45:23 EDT 2011


    [ https://issues.jboss.org/browse/JBSEAM-4694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12617898#comment-12617898 ] 

Michael K commented on JBSEAM-4694:
-----------------------------------

Attached is a diff file for the changes needed in QueryTest.java to reproduce the bug. The trick is that the current tests never use the SUBJECT_PATTERN, because Query.useWildcardAsCountQuerySubject is never set to false.

Add this to the testCountQuery() method:

      // trying to reproduce bug JBSEAM-4694
      query.setUseWildcardAsCountQuerySubject(false);
      query.setEjbql("select DISTINCT p from Person p");
      query.setOrderColumn("username");
      query.parseEjbql();
      // TODO this should eventually become count(p)
      assertEquals(query.getCountEjbql(), "select count(*) from Person p");
      query.setUseWildcardAsCountQuerySubject(true);

Add this to the inner class UnitQuery:

      /** Making setter method accessible for reproducing JBSEAM-4694. */
      public void setUseWildcardAsCountQuerySubject(boolean useCompliantCountQuerySubject) {
         super.setUseWildcardAsCountQuerySubject(useCompliantCountQuerySubject);
      }

Test outcome is:

 [testng] FAILED: testCountQuery
 [testng] java.lang.IllegalStateException: invalid select clause for query
 [testng] 	at org.jboss.seam.framework.Query.getCountEjbql(Query.java:319)
 [testng] 	at org.jboss.seam.test.unit.QueryTest$UnitQuery.getCountEjbql(QueryTest.java:81)
 [testng] 	at org.jboss.seam.test.unit.QueryTest.testCountQuery(QueryTest.java:40)


> Query class does not handle distinct query properly
> ---------------------------------------------------
>
>                 Key: JBSEAM-4694
>                 URL: https://issues.jboss.org/browse/JBSEAM-4694
>             Project: Seam 2
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 2.2.1.CR1
>            Reporter: Martin Frey
>            Priority: Critical
>         Attachments: JBSEAM4694-QueryTest.diff
>
>
> With the update from 2.2.0.GA to 2.2.1.CR1 the SUBJECT_PATTERN within the Query class has changed. This pattern does filter this query as a bad one:
> select distinct bean1 from Bean1 bean1, Bean2 bean2 where bean1 in elements(bean2.bean1s) order by bean1.id asc

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the seam-issues mailing list