Grails
  1. Grails
  2. GRAILS-8448

totalCount doesn't work with createAlias

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-RC3
    • Fix Version/s: 2.0 final
    • Component/s: Persistence
    • Labels:
      None
    • Environment:
      Win7, JDK 1.6 u27

      Description

      totalCount doesn't recognize aliases (defined with createAlias) resulting in: org.hibernate.QueryException (could not resolve property ...)

      I suspect it's because grails.orm.PagedResultList.getTotalCount() implementation doesn't add aliases of the original criteria instance to totalCriteria.

      Please check the attachment.

        Activity

        Hide
        Patraphong Sukhonpitumart added a comment -

        In fact, it doesn't work with association querying either.

        import org.hibernate.*
        
        def foos = Foo.createCriteria().list([max: 10, offset: 0]) {
          bar {
            eq('barName', 'John')
          }
        }
        
        println(foos.totalCount)
        
        Show
        Patraphong Sukhonpitumart added a comment - In fact, it doesn't work with association querying either. import org.hibernate.* def foos = Foo.createCriteria().list([max: 10, offset: 0]) { bar { eq('barName', 'John') } } println(foos.totalCount)
        Hide
        Leonid Vysochyn added a comment - - edited

        Having similar issue with RC3. We do not use aliases but have a lot of association queries. All of them are failing in RC3 and the latest snapshot build. So we had to revert to RC2 version that does not have such a bug.

        Show
        Leonid Vysochyn added a comment - - edited Having similar issue with RC3. We do not use aliases but have a lot of association queries. All of them are failing in RC3 and the latest snapshot build. So we had to revert to RC2 version that does not have such a bug.

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Patraphong Sukhonpitumart
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development