Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1267

rest/ResourceGeneratorUtil generates bogus id name from Method

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • 3.x Future
    • 1.4.2.Final, 2.0.0.Alpha13
    • Java EE
    • None

    Description

      The "rest endpoint-from-entity" command uses this class (ResourceGeneratorUtil).

      Everything works fine if the @Id annotation is attached to a field.

      However, if the @Id annotation is attached to the setXYZ() or getXYZ() method, ResourceGeneratorUtil ends up producing an incorrect name for the id property: the name should be "xyz" but this class incorrectly produces "txyz".

      The problem is that the code in ResourceGeneratorUtil invokes substring(2) when it should actually have used substring(3). One site in the class correctly uses substring(3) but there are four other sites that use substring(2).

      The workaround is to attach @Id to the field, not to the setter or getter methods.

      Probably this bug has lain low because (a) the "entity" command always attaches @Id to the field, and (b) the JBoss Tools "New JPA Entity" wizard has an "Access Type" radio button that defaults to using the field, so the bug is only triggered if you explicitly change the radio button (or use an editor to attach the @Id annotation).

      Attachments

        Activity

          People

            Unassigned Unassigned
            tm2_jira Thomas Maslen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: