How to modify existing entity generated with jhipster?

1) Edit the json file representing your entity (add/remove field, the syntax is pretty easy, check in the end of the file if is required any change to the general entity properties like 'fieldsContainOneToMany'...), you'll find it in:

<jhipster_root_folder>/.jhipster/entityName.json

2) Build the code.

3) In the root of your project run the command:

yo jhipster:entity entityName

NOTE: this command by default overwrite all your manual changes. I recommend to do a commit on a VCS repository before to run this command to eventually revert any not required change.

4) run

mvn liquibase:diff

I have solution worked for jhipster 3.4.2, it is the result of me in 1 day, hope it helpful to you :)

  1. Run yo jhipster:entity entityName
  2. Modify entities (add, remove, ...), at the end, jhipster will give question to override file, *IMPORTANT NOTE: select NO for changelog .xml file and navbar.html file.
  3. Back to project and run mvn compile liquibase:diff
  4. Run your application
  5. DONE

You can also modify existing entities interactively, e.g. using yo jhipster:entity Foo for entity Foo.

This way, you can regenerate all entities and dialogs.

If you are using a RDBMS and liquibase, you have to write the changelog file(s) and add it to the master.xml. What helps here is using mvn liquibase:diff or gradlew liquibaseDiff, which you can run against your existing DB. Though, I would recommend to write the changelog files manually.


In the same page you can see this sentence:

If you have choosen to use MySQL or Postgresql in development, you can use the mvn liquibase:diff goal to automatically generate a changelog.

Liquibase Hibernate is a Maven plugin that is configured in your pom.xml, and is independant from your Spring application.yml file, so if you have changed the default settings (for example, changed the database password), you need to modify both files.

Here is the development workflow:

Modify your JPA entity (add a field, a relationship, etc.) Compile your application (this works on the compiled Java code, so don't forget to compile!) Run mvn liquibase:diff (or mvn compile liquibase:diff to compile before) A new "change log" is created in your src/main/resources/config/liquibase/changelog directory Review this change log and add it to your src/main/resources/config/liquibase/master.xml file, so it is applied the next time you run your application If you use Gradle instead of Maven, you can use the same workflow by running ./gradlew liquibaseDiffChangelog, and change the database configuration in liquibase.gradle if required.

So you just need change your JPA entities (remove, add, etc), run mvn compile liquibase:diff, and put the changes in master.xml.


For jhipster 5.7.0 you can run the entity command again and it will ask if you want to modify it.

 % jhipster entity device                                 
INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:entity device
INFO! Options: from-cli: true

Found the .jhipster/Device.json configuration file, entity can be automatically generated!


The entity device is being updated.

? Do you want to update the entity? This will replace the existing files for this entity, all your custom code will be overwritten 
  Yes, re generate the entity 
❯ Yes, add more fields and relationships 
  Yes, remove fields and relationships 
  No, exit