user115524 user115524 - 1 year ago 354
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download