facebook

Leave Generated Directory Alone?

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #318398 Reply

    Mork
    Participant

    Hello,

    From a code development standpoint, is it a good idea to leave the /generated directory totally alone and just create classes in /src that reference the classes in /generated?

    That way, if the database ERD changes for already-“generated” classes (which it will!), you wouldn’t have any of the code you put in /generated classes to re-modify.

    I’m not sure if MyEclipse for Spring can readily handle merging, say, a changed Service class in the /generated directory (with code I may have added) with a new reverse engineered Service class from the database for the same class.

    So, to get around these types of (potential) overwriting/merging problems, my question is whether it’s best to just leave /generated alone and create references (classes) to it from /src.

    What is the best practice here?

    Thanks,

    – M

    #318439 Reply

    jkennedy
    Member

    In general, we try not to remove code that you have added to java classes. So methods that you have added to java classes should be retained. If you modify existing methods, those changes should remain as well.

    There may be a few areas where the merge may not come off as expected.
    1) Adding a field to a domain object will not update the service impl save method with the new field. So you would have to manually update that code.
    2) Changing a primary key may not entirely update the @id annotation on your domain objects, unless it is a new column.
    3) Changing a primary key may cause duplicate methods with different signatures in the controller, service and dao objects.
    4) Named queries for the newly generated field(s) may not be merged in.

    As for JSP pages, they are always overwritten.

    We should note here that when you run scaffolding again, that you can turn off each “layer”, for example, you can rerun the persistence and service layer scaffolding but uncheck the web layer scaffolding to preserve changes you made to the JSP pages.

    Our order of preference regarding the use of the code in the generated folder is as follows:

    1. Use – Where ever possible, use Spring to load references to the Services, DAO, etc from your own code, and add additional logic etc in your own classes.

    2. Extend – Where you might need to override logic etc, if you can extend the code in the generated folder that is preferred

    3. Modify – If you need to directly modify the code files in the Generated code folder, we do support that with limitations as noted above.

    You are correct that if at all possible, it is best to leave the generated code alone such that you can more gracefully deal with re-running scaffolding either for DB changes.

    Thanks,
    Jack

    #318445 Reply

    Mork
    Participant

    Thanks Jack!

    We truly appreciate your company’s wonderful support.

    – M

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Leave Generated Directory Alone?

You must be logged in to post in the forum log in