Announcement Announcement Module
Collapse
No announcement yet.
Automatic ID and Column fields Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatic ID and Column fields

    I am having fun trying this tool out, but I have a question.

    When Roo creates a new entity (as an example I will use a class called Cycle) using
    Code:
    new persistent class jpa -name ~.Cycle
    a Cycle_Roo_Entity.aj file is created which contains (among other things) an id field and version field which are mapped to the columns "id" and "version". Is there a way to customize this?

    In my particular case I do not have much control over the database and in most cases the only version column in the table would probably be an "update_date" column (which besides having a different column name is also a date instead of integer). Furthermore, our id column is not always called "id". For instance on an table called CYCLE the id field may be called "CYCLE_ID".

    I tried to make edits the Cycle_Roo_Entity.aj file by hand in eclipse but Roo just changed them back.

    Thanks,
    Chris

  • #2
    You cannot change .aj files, these files are "managed" by Roo. Instead, add the id field and the getter and setter to the Cycle class and annotate as you require. When you save the Cycle.java file you'll notice that Roo removes the id and it's getter and setter from the Cycle_Roo_Entity.aj file. If you copy the values from the Cycle_Roo_Entity.aj make sure you remove the "Cycle." prefix

    Comment


    • #3
      Thanks rhart. Another way is to use the @RooEntity annotation attributes, so you can do things like @RooEntity(identifierField="myOtherName"). There are various attributes in the class to fine-tune version etc. Because this annotation appears on your .java file, you can edit it easy and still have the benefits of Roo auto-managing your ITDs.

      Comment


      • #4
        Perfect, thanks for the help Ben and rhart.

        Comment

        Working...
        X