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

Alessandro Lazarotti commented on JBSEAM-4744:
----------------------------------------------

It's happen because Seam 2.0.x have this code in 
org.jboss.seam.framework.Query.java:

   protected String getCountEjbql()
   {
      (...)
      return "select count(*) " + ejbql.substring(fromLoc, orderLoc);
   }


It's works for Hibernate, but by spec, the right way is not uses * but a alias, 
and the wildcard can be not portable for another provider. I think because of 
this the implementation in Seam 2.2.x has been changed to:

   protected String getCountEjbql()
   {
      (...)
      else if (useWildcardAsCountQuerySubject) {
         subject = "*";
      }
      (...)
        return new StringBuilder(ejbql.length() + 15).append("select 
count(").append(subject).append(") "
   }

and useWildcardAsCountQuerySubject is setted by 
org.jboss.seam.persistence.HibernatePersistenceProvider:

   @Override
   public void init()
   {
      super.init();
      featureSet.add(Feature.WILDCARD_AS_COUNT_QUERY_SUBJECT);
   }

... but "init" is never called, and useWildcardAsCountQuerySubject is ever 
false, causing the issue. To fix, move the code from "init" to constructor:

   public HibernatePersistenceProvider()
   {
          super.init();    
      featureSet.add(Feature.WILDCARD_AS_COUNT_QUERY_SUBJECT);
   }


> EntityQuery.resultList throws a exception when the entity has composite key
> ---------------------------------------------------------------------------
>
>                 Key: JBSEAM-4744
>                 URL: https://issues.jboss.org/browse/JBSEAM-4744
>             Project: Seam
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 2.2.0.GA, 2.2.1.CR1
>         Environment: Fedora 12, JDK 1.6 sun/oracle, Seam 2.2.1 CR1, MySQL 5
>            Reporter: Alessandro Lazarotti
>              Labels: entity-query, hibernate
>             Fix For: 2.2.1.Final
>
>
> Hibernate has a known trouble running queries using "count" when the entity 
> has composite keys, like: 
>    select count(foobar) from Foobar foobar:
>  - ERROR [JDBCExceptionReporter] Operand should contain 1 column(s)
> Seam EntityQuery has a workaround, using count(*) instead of 
> count(alias)(spec way) if you use entityQuery.resultCount. 
> It's works with Seam 2.0.x but no more in Seam 2.2.x

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

        
_______________________________________________
seam-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/seam-issues

Reply via email to