Search code examples
jhipsterjdl

Splitting JDL file to extend model step by step


A freshly generated JHipster application contains already a basic model (e.g. with an User entity), lets call it m0. I extended m0 by defining a model m1 with the JHipster Domain Language (JDL) and generating the entities. For the authorization layer m1 had to reference the User in m0. I was able to achieve that by defining the User entity in the m1.jdl file like this:

entity User{}

The already existing User entity was not regenerated, only referenced from m1 - great!

Since m1 has to be extended with new entities regularly, it would be a dream to use the same pattern for m2, m3 referencing an entity in m1. But when I define AnM1Entity in m2.jdl like this:

entity AnM1Entity{}

Unfortunately AnM1Entity{} is regenerated and all attributes defined in m1.jdl for AnM1Entity are lost.

Why is User not regnerated and AnM1Entity is regenerated? Is there a way to skip the generation of AnM1Entity?

Or is there another way to extend JHipster application models in a convenient way?

thanks


Solution

  • User is never generated because it's not a JHipster entity, same for Authorities and all other predefined classes that are mapped to tables from initial database schema.

    JDL does not support what you want.

    If your goal is to preserve your manual changes from being overwritten by re-generation, you should have a look at what the community calls side-by-side approach:

    Alternatively, you can rely on git by always generating on a branch and merging on master with git merging strategy options.