Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-3275

Generated mvc scaffold with compilation error at entity with same name and identifier field name

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 1.2.2.RELEASE
    • Fix Version/s: 1.2.3.RELEASE
    • Component/s: WEB MVC
    • Labels:
    • Environment:
      Ubuntu 12.04, JDK 1.0.6_33, Maven 3.0.4

      Description

      Generate a web mvc application and scaffold it with next script:

      project --topLevelPackage org.gvnix.test
      jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
      entity jpa --class ~.domain.Car --identifierField car
      field string --fieldName name
      web mvc setup
      web mvc all --package ~.web
      

      When entity name and identifier field has the same name, a compilation error occurs:

      [ERROR] /tmp/test/src/main/java/org/gvnix/test/web/CarController_Roo_Controller.aj:79:0::0 Duplicate local variable car
      [ERROR] error at Car car = Car.findCar(car);
      

      This happens because method parameter and method local variable have same name:

          @RequestMapping(value = "/{car}", method = RequestMethod.DELETE, produces = "text/html")
          public String CarController.delete(@PathVariable("car") Long car, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
              Car car = Car.findCar(car);
              ...
          }
      

      I attach the example project.

        Attachments

          Activity

            People

            Assignee:
            stewarta Alan Stewart
            Reporter:
            mmartinez Mario Martínez Sánchez - gvNIX - DISID
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0.25d
                0.25d
                Remaining:
                Remaining Estimate - 0.25d
                0.25d
                Logged:
                Time Spent - Not Specified
                Not Specified