Announcement Announcement Module
Collapse
No announcement yet.
Changes to @RooEntity don't reflect in code Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changes to @RooEntity don't reflect in code

    I have a project that was not the result of a db reverse engineering. It was built entirely in roo (1.1.3). However, I'd like to change things like the schema used for certain entities and the identifier generation (why does roo default to using a single sequence for all entities - that seems counterintuitive. Wouldn't the usual case be to have an auto incremented column of some kind in each entity table?).

    Apparently, the RooEntity annotation should allow me to specify values for table and schema, but I cannot get roo to re-generate the _Roo_Entity.aj file with the new values. I thought that the whole point of roo's round tripping was that it would notice such changes and automatically accommodate them. I've tried changing just the annotation in the java file, changing the annotation and removing the old _Roo_Entity.aj file, changing the annotation and removing the relevant content from within the _Roo_Entity.aj file without adding it to the .java file - so roo should re-generate it. All of these have been followed by the 'poll now' command in the roo shell - both in a terminal and in the STS roo shell.

    I'm using STS Version: 2.6.0.RELEASE Build Id: 201103161000 which came with roo 1.1.3

    If I have to completely regenerate any entity I wish to modify in order to get roo to make the changes, roo becomes pretty much unusable as soon as I've added my own code to any given entity.

    There must be something I'm missing about making changes to @Roo... annotations.

  • #2
    For the record, I've got the following @RooEntity annotation


    Code:
    @RooEntity(identifierColumn="account_id", schema="some_schema", table="acc")
    public class Account {
    }
    but the generated code still looks like this:

    Code:
    privileged aspect Account_Roo_Entity {
        
        declare @type: Account: @Entity;
        
        @PersistenceContext
        transient EntityManager Account.entityManager;
        
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        @Column(name = "id")
        private Long Account.id;
        
        @Version
        @Column(name = "version")
        private Integer Account.version;
    
    ...
    }

    Comment


    • #3
      OK, now I'm starting to think that this is a critical roo bug. I attempted to create an entirely new entity just to see what the generated code would look like.

      I executed the following command in the roo shell:

      Code:
      roo> entity --class ~.domain.HelpMe --schema ecorithm --table blah
      Created SRC_MAIN_JAVA/com/ecorithm/domain/HelpMe.java
      (holy shit is it ever annoying that you can't actually copy content from the roo console in eclipse which includes the console's output - I have to copy the command (without the shell prompt) then the output)

      Note that it did NOT generate any of the aspects for the entity. It did generate the annotations for them, but no code was generated.

      However when I add the ''--testAutomatically" option to the command, I get a fully generated entity, including the aspects

      Code:
      roo> entity --class ~.domain.HelpMe --schema ecorithm --table blah --testAutomatically
      Created SRC_MAIN_JAVA/com/ecorithm/domain/HelpMe.java
      Created SRC_TEST_JAVA/com/ecorithm/domain/HelpMeDataOnDemand.java
      Created SRC_TEST_JAVA/com/ecorithm/domain/HelpMeIntegrationTest.java
      Created SRC_MAIN_JAVA/com/ecorithm/domain/HelpMe_Roo_Entity.aj
      Created SRC_MAIN_JAVA/com/ecorithm/domain/HelpMe_Roo_ToString.aj
      Created SRC_MAIN_JAVA/com/ecorithm/domain/HelpMe_Roo_Configurable.aj
      ~.domain.HelpMe roo>
      So it appears that aspect generation is broken in roo-1.1.3 and only occurs when --testAutomatically is issued and there is no subsequent validation of the generated code.

      If I modify HelpMe.java to include the following, I'd expect the same lines to be removed from HelpMe_Roo_Entity.aj - but they are not

      Code:
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          @Column(name = "helpme_id")
          private Long id;
      over in the .aj file, I've still got the following:

      Code:
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          @Column(name = "id")
          private Long HelpMe.id;
      This makes roo unusable. It is a critical, blocker bug so far as I can tell.

      Comment


      • #4
        It gets more interesting.

        I have the web scaffolding generated by roo. In one controller, I pushed in exactly one method

        Code:
        @RooWebScaffold(path = "thermalspaces", formBackingObject = ThermalSpace.class)
        @RequestMapping("/thermalspaces")
        @Controller
        public class ThermalSpaceController {
            @RequestMapping(value = "/{id}", method = RequestMethod.GET)
            public String show(@PathVariable("id") Long id, Model uiModel) {
                uiModel.addAttribute("thermalspace", ThermalSpace.findThermalSpace(id));
                uiModel.addAttribute("itemId", id);
                return "thermalspaces/show";
            }    
        
        }
        Note that the method in question is unchanged from the version generated by roo in the _Roo_Controller.aj aspect.

        I was getting the following warnings (or, at least, I took them to be warnings) when the roo shell initialized

        Code:
        Undo manage SRC_MAIN_WEBAPP/WEB-INF/i18n/application.properties
        Method 'show' already defined in target type 'com.company.web.ThermalSpaceController' (ITD target 'com.company.web.ThermalSpaceController_Roo_Controller')
        I assumed that was just the roo shell telling me that it had found my version of the method so it was not generating the same thing in the aspect - and, indeed, the method was not generated. However, it was apparently preventing the shell from doing any further work when scanning the filesystem for changes. As soon as I commented out the controller method in the java file and re-launched the roo shell, the shell detected all of my changes and proceeded to re-generate everything as I had been expecting it to do.

        So my question is - if I need to modify a web scaffold controller method so that I can add something else to the model, how can I do so without breaking my entire roo project?

        Comment

        Working...
        X