user115524 user115524 - 9 months ago 216
AngularJS Question

How to properly extend JHipster User Entity

I started a new JHipster project recently and I have a requirement in the project for extending a built-in User entity.

For example to add some new attributes (and columns in the database to persist those). But, since this is built-in functionality and the User entity is not listed in .jhipster folder I'm wandering of a proper way to do it.

The simplest option would be to change and liquibase migration xmls and all associated files but that would probably be an obstacle for future jhipster upgrades (running

yo jhipster
inside project folder like it is explained here jhipster docs ).
Another possible route could probably be to create a new entity which would be in a one-to-one relation to the User entity, but I'm not sure how to exactly do this: Using
yo jhipster:entity
or ?

Has anyone successfully done this previously? What are the best practices I should follow in this case?


Easiest solution to be able to easily follow JHipster upgrades is to create a new entity (e.g. UserExtraInfo) with a one-to-one relationship with User and the owner of the relationship should be the new entity as we don't want to modify User. You'd generate the new entity using yo jhipster:entity.

Due to a related issue you must use release JHipster 3.5.0 at least to get this working.