Grails
  1. Grails
  2. GRAILS-8289

Problems with list-backed collection

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-RC1
    • Fix Version/s: 2.0-RC2
    • Component/s: Persistence
    • Labels:
      None
    • Environment:
      Windows7

      Description

      In the attached bug-report project, a hasMany relationship backed by a List of Book in Author:

      1. Adding a Book and then editing that book modifies the books_idx column as if it were adding a new Book, i.e. if there is only 1 Book in books it bumps the books_idx from 0 to 1 causing an exception to be thrown when attempting to show the Author.

      2. After adding multiple Books, if any Book but the last one is deleted, a gap is left in the books_idx causing an exception to be thrown when attempting to show the Author. I work around this in the BookController, see the try block in the delete method, by first deleting the Book from the Author's books collection before saving. I don't know if there's a way to detect this situation and do it automatically.

      3. The documentation concerning "Lists of Objects" in Section 5.2.4 should probably be updated to more accurately reflect the true current state of affairs. It currently says the code, presumably in the BookController should first addToBooks but it does not need to be done, unlike the corresponding delete.

      This appears related to fixes made in GRAILS-3783.

        Activity

        Hide
        Graeme Rocher added a comment -

        Jeff - could you have a look at this one?

        Show
        Graeme Rocher added a comment - Jeff - could you have a look at this one?
        Hide
        Jeff Scott Brown added a comment -

        Will do.

        Show
        Jeff Scott Brown added a comment - Will do.

          People

          • Assignee:
            Jeff Scott Brown
            Reporter:
            Ken Krebs
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development