Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: 1.0.2.RELEASE
    • Fix Version/s: 1.1.0.RC1
    • Component/s: PERSISTENCE
    • Labels:
      None

      Description

      I think Roo's implementation of mappedsuperclass could be improved.
      e.g. currently a script like:

      persistence setup --provider HIBERNATE --database MYSQL --databaseName roodb
      entity --class ~.domain.Human --abstract --mappedsuperclass
      entity --class ~.domain.Man --extends ~.domain.Human --testautomatically

      seems to be the suggested way to create a mappedsuperclass inheritance structure.

      However, this results in 2 problems:

      1) The mappedsuperclass itself is generated with an @entity annotation. I don't think this is correct as it results in the ORM creating a DB table for the mappedsuperclass, this doesn't seem right and is never populated with any data.
      Also, the sun docs say a mappedsuperclass shouldn't have an @entity annotation.

      2) The tests fail, as Alex observes in ROO-292. This is an AssertError, and it kind of kills the advantage of auto generated tests when you can't build the project in mvn. Something which may be preferable at times.

      Possible solutions could be:

      1) Maybe the --mappedsuperclass option should be moved to the Roo class command? It may be a better fit as a mappedsuperclass isn't a standard @entity.

      2) Manually remove the @entity annotation from the mappedsuperclass after Roo makes it? This makes the tests work again and hibernate no longer makes the redundent superclass table.

      Suggestions welcome.

      Nick.

        Issue Links

          Activity

          Hide
          Edwin Lukaweski added a comment -

          Seems to me that roo should adhere to the standard and not have both @Mappedsuperclass and @Entity at the same time

          Show
          Edwin Lukaweski added a comment - Seems to me that roo should adhere to the standard and not have both @Mappedsuperclass and @Entity at the same time
          Hide
          Alan Stewart added a comment -

          @Entity is now introduced via the entity ITD so that @MappedSuperclass can be detected on .java file. @Entity will not be added if the class is annotated with @MappedSuperclass. Fixed in Git ID f8e02c4b40cc93fd9e83f166241dbd491d2ca725

          Show
          Alan Stewart added a comment - @Entity is now introduced via the entity ITD so that @MappedSuperclass can be detected on .java file. @Entity will not be added if the class is annotated with @MappedSuperclass. Fixed in Git ID f8e02c4b40cc93fd9e83f166241dbd491d2ca725
          Hide
          Alan Stewart added a comment -

          Did check instead for @Entity and @MappedSuperclass in .java file - could not have @Entity introduced in ITD

          Show
          Alan Stewart added a comment - Did check instead for @Entity and @MappedSuperclass in .java file - could not have @Entity introduced in ITD

            People

            • Assignee:
              Alan Stewart
              Reporter:
              Nick L
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: