JHipster, what is the order of creating objects

I am trying to run an application, and my idea was to erase objects using the command line first, and then work with the user interface. This turned out to be more complicated than I thought, because under certain circumstances you get a warning that the generator will not work. This is similar to whether it is OneToMany or ManyToOne, or whether this entity is a relationship ownership.

What is the best way to do this?

If I can work out the rules, I can decide in what order to create things. My concern is that with a complex scheme there is no order that can work without any warnings and things that don't work.

My other idea was to generate entities without relationships first, and then edit json files to add relationships. Then, perhaps, I can start the generator again on each object. Not sure if this will work, and I'm not 100% sure of the correct json properties needed.

What have other people tried?

+5
source share
2 answers

Plan your entities and relationships, so that when you create an entity, all the entities on which it depends are already created. One way to do this is to use a schema constructor or simply document objects and place them in the order in which they should be created.

Otherwise, as you know, you will have to manually link these relationships or recreate them with an entity generator.

But even when planning, you will have to use a mixture of these methods in the real world. It only depends on how much you modified the generated code, which method is the fastest.

+5
source

Rory's answer is basically what I did, but I would like to provide more information.

First, I went through the generator and created all types of relationships to see which ones were processed and which ones were a warning. I found that sometimes it worked, and sometimes it is not, but it was not registered anywhere.

These relationships always work.
OneToMany
OneToOne (not owner)
ManyToMany (not owner)

These relationships only work when another object already exists.
ManyToOne
OneToOne (owner)
ManyToMany (owner)

The reason they do not work is always the same. All of them require that the foreign key be created on another table, which jHipster cannot do if it does not already exist. Of course, you could ignore the warning, but I was not sure if that meant something else would not work.

Based on these rules, I compiled a list of my entities and placed them in an order that would work without warning. If the object had relationships that might give a warning, I just made sure another object was created first.

It seems to have worked. The only thing I found out is that the generator is a one-time thing (you cannot use it to modify the entity), you need to know your circuit in front and generate a batch at a time.

+4
source

Source: https://habr.com/ru/post/1213733/


All Articles