Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.3.1
    • Fix Version/s: 1.1-beta1
    • Component/s: Persistence
    • Labels:
      None

      Description

      I would be nice if you could specify a default sort and order for domain classes, like:

      class NewsArticle

      { static defaultSort = 'publishedAt' static defaultOrder = 'desc' String title Date publishedAt .... }

        Issue Links

          Activity

          Hide
          Dennis Carroll added a comment -

          All my attempts to implement Graeme's suggestion have not succeeded.
          I will try to attach the code (w/test) I used.

          Show
          Dennis Carroll added a comment - All my attempts to implement Graeme's suggestion have not succeeded. I will try to attach the code (w/test) I used.
          Hide
          Josh Brown added a comment -

          I found that this doesn't work when the property is a camelCased word. For example:

          class Book

          { Date dateCreated }

          class Author {
          static hasMany = [books:Book]

          static mapping =

          { books sort:'dateCreated' }

          }

          Running the app produces an exception similar to the following:

          ERROR util.JDBCExceptionReporter - Column not found: BOOKS0_.DATECREATED in statement ...

          The problem is that the database column is date_created, not datecreated. The camelHumps property should be translated in the query to two words separated by an underscore.

          Show
          Josh Brown added a comment - I found that this doesn't work when the property is a camelCased word. For example: class Book { Date dateCreated } class Author { static hasMany = [books:Book] static mapping = { books sort:'dateCreated' } } Running the app produces an exception similar to the following: ERROR util.JDBCExceptionReporter - Column not found: BOOKS0_.DATECREATED in statement ... The problem is that the database column is date_created, not datecreated. The camelHumps property should be translated in the query to two words separated by an underscore.
          Hide
          Justin Edelson added a comment -

          Did the issue that Josh reported above get resolved? I'm seeing this same problem in 1.2.1.

          Show
          Justin Edelson added a comment - Did the issue that Josh reported above get resolved? I'm seeing this same problem in 1.2.1.
          Hide
          Tomas Metz added a comment -

          The problem persists. I have just upgraded from 1.1.2 to 1.3.1 and the application even did not started. I have an attribute in the domain 'int itemOrder', using for default sort and for the 1.3.1 it was necessary to change: name 'itemOrder' -> name 'item_order'.

          Show
          Tomas Metz added a comment - The problem persists. I have just upgraded from 1.1.2 to 1.3.1 and the application even did not started. I have an attribute in the domain 'int itemOrder', using for default sort and for the 1.3.1 it was necessary to change: name 'itemOrder' -> name 'item_order'.
          Hide
          Alexander Zeillinger added a comment -

          Broken in 1.3.7 when sorting dates, order is always ascending.

          Show
          Alexander Zeillinger added a comment - Broken in 1.3.7 when sorting dates, order is always ascending.

            People

            • Assignee:
              Graeme Rocher
              Reporter:
              Paul Barry
            • Votes:
              10 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development