Closed liuxx532 closed 9 years ago
Hope I have demonstrated clearly, Thank you.
You could create a new entity with your additional data and just a relation between user and your new entity.
Maybe the default entities like User could have a JSON description in .jhipster directory as custom ones have and so could be extended using entity sub generator?
:+1: @gmarziou Sounds great (what when the developer removes required fields?)
Well if you use a knife, you can hurt yourself and git is your best friend ;)
Yes of course, but you never know what people try to do ;)
@atomfrede your idea could be work. But how can I build the relation between the new entity and user? If With a foreign key I also need to expand the filed. The previous question comes back again
@liuxx532 as of now you have to manually edit the entity and changelog files by hand to achieve this. You can create a userProfile entity and have it as a one to one in user entity but u have to manually add that in the user entity and edit changelog to add the foreignkey of userProfile to usertable
@deepu105 I think Your suggestion is quit similar as @atomfrede, and actually I was trying to approach that. Firstly I tried to re-generate the user with a additional foreign key, but u know User is related with Anthority and PersistentToken, I tried my best to rebuild the relationships among them three, however there are always some errors(too much import and dependencies make the rebuild get very hard.)
I think many people sometimes want to re-generate the User entity to meet different kinds of requirements. Then I am to state my way to approach that, definitely it is not totally correct(Lol) but I hope we can discuss. Firstly, yo jhipster:entity user. Fill the fileds in, set authorities as Integer, set persistentTokens as Integer as well, build one2many relationship with Authority and PersistentToken respectively. Build many2one relationship with PersistentToken by "Id" Secondly, yo jhipster:entity Authority, fill fileds in, build many2one relationship with user by "id".
Thirdly, yo jhipster:entity PersistentToken. Fill fields in, set "user" as integer, build many2one relationship with user by "id", and build one2many relationship with user by "user".
Hopefully, you can understand the way that I described above. More than welcome to point out the Errors or Bad choice. (@deepu105, @atomfrede,@gmarziou)
@jdubois Hope you can come to here, and give me some suggestion. Please have a look the process to rebuild the User entity is correct or not. Thank you very much.
@liuxx532 , extend the table JHI_USER. I made tree types of user using generalization.
@phouverneyuff Thanks a lot for your ERD, but it looks like I am unable to see the full diagram(cannot see the right part), and I cannot access the url: """ http://infocenter.sybase.com/archive/index.jsp?topic=/com.sybase.stf.powerdesigner.docs_12.0.0/html/clug/clugp114.htm """.
Thank you.
@liuxx532 , I cut my ERD to you see only this part.
I made generalization. Gestor(manager), Cliente(client) and Funcionario(employee) are kind of User. The relationship between them are one-to-one(1:1).
Type in Google Images "Generalization" and you will see other examples.
@atomfrede As a JHipster-UML guy, I couldn't agree more. Composition is the best solution (and it should be preferred over inheritance in this case). The only advantage inheritance has (here) is that we don't have to modify the User entity. However, inheritance still needs to be correctly implemented (which, to my knowledge, is not). On the other hand, composition requires the User entity to be altered... if we don't use unidirectional associations. We (the JHipster-UML team) encountered this case before, and dealt with it by removing associations going from User (but we kept the ones going to User), and converting bidirectional associations to unidirectional ones.
-> so I would use my first solution, which is really basic in fact
ERROR! The table name cannot contain a PostgreSQL reserved keyword
I have the same error when trying to add a new relationship (1-1) User(newEntity_id) - NewEntity(id).
Any solution?
Please don't camp on old issues, open a new one and follow our guidelines
Hello, I just start to work on Jhipster, and got a question "Can I modify the exiting User entity field (normally expand the field) ?"
Like, sometimes I want to collect more information from users when users register. I tried to "yo jhipster:entity user" to expand the filed, however, I am failed. I record the original field and typed them in when I "yo jhipster:entity user", but there are many methods related to the original field and I am unable to handle them very well.
So, I hope you have a good way to expand the user field, and share with me. Thank you very much.