Results 1 to 4 of 4

Thread: Ovewriting toString() in entity deletes all *.aj

  1. #1
    Join Date
    Jan 2010
    Location
    Lanus, Argentina
    Posts
    28

    Default Ovewriting toString() in entity deletes all *.aj

    First of all, Which is the right word "overwrite" or "override"? (Please don't reply that override is a method of java.util.horse)

    In the meantime I'll use overwrite.

    The point is that if I overwrite the toString() method in an entity, Roo deletes all the *.aj files, and that means that it deletes all the functionality from:
    *_Roo_Entity.aj
    *_Roo_Finder.aj
    *_Roo_JavaBean.aj

    So I have to copy all the code in these files to the java file (entity) if I donīt want to lose all that code.

  2. #2
    Join Date
    Jan 2010
    Location
    Lanus, Argentina
    Posts
    28

    Default

    Another newbie error (of mine).....
    Roo only deletes all *.aj files if you overwrite toString() in the way it's written in the *_Roo_ToString.aj file, in a static way like:

    public String ZZZClass.toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("xxxx");
    return sb.toString();
    }

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

    Default

    Roo will only delete the _Roo_ToString.aj file if you override the toString() method by providing one in the normal .java file.

    If Roo is deleting all the *.aj files, I suspect it's a syntax error in the .java file. When Roo cannot parse a .java file it cannot be sure you really want it to have written any ITDs. It therefore acts conservatively by removing them. After all, it can create them again as soon as the syntax error is removed, the .java can be parsed, and one or more @Roo* annotations therefore read in and treated as a directive to produce an ITD.

    Hope this explanation assists.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  4. #4
    Join Date
    Jan 2010
    Location
    Lanus, Argentina
    Posts
    28

    Default

    And Roo is behaving exactly as you have just explained...
    It was a syntax error ( I wasn't using eclipse IDE), so I didn't see it clearly...
    Thanks for the reply...

Posting Permissions

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