Grails
  1. Grails
  2. GRAILS-2411

Inheritance Mapping Creates Incorrect Schema When tablePerHierarchy Is False

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.0.2
    • Component/s: Persistence
    • Labels:
      None

      Description

      Currently when a superclass indicates that a table per subclass strategy should be used in the static mapping closure (tablePerHierarchy false), Grails erroneously generates a "NOT NULL" or required "class" column in the superclass' table. This results in failures during insert and update statements while Hibernate attempts to persist data. The failure is because the SQL statements generated do not contain the syntax to store data in the unnecessary "class" column. The generated statements are correct as the "class" column should only be required/exist when a superclass and all its subclasses are stored in the same table (e.g. when the "class" column is the discriminator column and tablePerHierarchy is set to true).

      The fix would require that the "class" column only be created when the tablePerHierarchy mapping term is set to true. For versions affected by this bug, it appears simply removing the "class" column from the superclass' table allows Grails to operate as expected.

        Issue Links

          Activity

          Hide
          Martyn Hiemstra added a comment -

          I got this error but it was because my parent object wasn't abstract. Try making the parent object abstract and add tablePerHierarchy false to the parent objects mapping and then it should work.

          Show
          Martyn Hiemstra added a comment - I got this error but it was because my parent object wasn't abstract. Try making the parent object abstract and add tablePerHierarchy false to the parent objects mapping and then it should work.

            People

            • Assignee:
              Graeme Rocher
              Reporter:
              oakridge
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development