Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-5590

EntityQuery.resultCount throws a exception when the entity has composite key

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: EAP 5.0.1, EAP 5.1.0 Post Release
    • Fix Version/s: EAP_EWP 5.1.1
    • Component/s: Seam
    • Labels:
      None
    • Environment:

      Fedora 12, JDK 1.6, JBoss EAP 5.1, MySQL 5

    • Affects:
      Release Notes
    • Release Notes Text:
      Hide
      Invoking EntityQuery.resultCount() resulted in a query such as <code>select count( entity )...</code>. However, if the persistence provider is Hibernate and the Entity has a composite key, the exception <code>[ERROR JDBCExceptionReporter] Operand should contain 1 column(s)</code> is triggered, because Hibernate does not support composite keys in <code>count</code> queries.

      This constraint prevented you from using seam-gen and JBoss Developer Studio to generate CRUDs if you had Entities with composite keys and you use Hibernate. Hibernate extensively uses <code>EntityQuery.resultCount()</code> in the generated code, and this class triggered the exception.

      Seam has been updated, so that if the persistence provider is Hibernate, Seam builds the query using the notation <code>select count( * )</code> instead of <code>select count ( entity )</code>. This method works, even with composite keys. With this fix in place, <code>EntityQuery.resultCount()</code> works for all entities and all persistence providers, as do generated CRUDs.
      Show
      Invoking EntityQuery.resultCount() resulted in a query such as <code>select count( entity )...</code>. However, if the persistence provider is Hibernate and the Entity has a composite key, the exception <code>[ERROR JDBCExceptionReporter] Operand should contain 1 column(s)</code> is triggered, because Hibernate does not support composite keys in <code>count</code> queries. This constraint prevented you from using seam-gen and JBoss Developer Studio to generate CRUDs if you had Entities with composite keys and you use Hibernate. Hibernate extensively uses <code>EntityQuery.resultCount()</code> in the generated code, and this class triggered the exception. Seam has been updated, so that if the persistence provider is Hibernate, Seam builds the query using the notation <code>select count( * )</code> instead of <code>select count ( entity )</code>. This method works, even with composite keys. With this fix in place, <code>EntityQuery.resultCount()</code> works for all entities and all persistence providers, as do generated CRUDs.
    • Release Notes Docs Status:
      Documented as Resolved Issue

      Description

      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

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  alessandrolt Alessandro Lazarotti
                  Reporter:
                  alessandrolt Alessandro Lazarotti
                  Writer:
                  Misty Stanley-Jones
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: