Results 1 to 4 of 4

Thread: Automatic ID and Column fields

  1. #1
    Join Date
    Oct 2007
    Location
    Albany, NY
    Posts
    16

    Default 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. #2
    Join Date
    Nov 2008
    Location
    Swansea, Wales
    Posts
    202

    Default

    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

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    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.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  4. #4
    Join Date
    Oct 2007
    Location
    Albany, NY
    Posts
    16

    Default

    Perfect, thanks for the help Ben and rhart.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •