Meier
Meier

Reputation: 3880

Adding entity with relationship to existing entity in jhipster

I have an Jhipster app with an existing entity Company. Now I want to add an Entity Vehicle and created an "vehicle.jh" file for the generator, like this:

entity Vehicle {
    name String
    category String 
    // ...
}
relationship OneToMany {
    Company{vehicles} to Vehicle{owner}
}

On the first try, the generator complained it does not know about "Company". I then tried to add it an empty declaration, like this

entity Company

But this overwrites the existing Company-entity classes and removes the existing fields in them.

Is it possible to generate a new entity and connects it with the existing entities, if yes, how? Or should I redoing the steps done the generator by hand, or (or use git to merge them somehow with the original source files)

Upvotes: 2

Views: 2654

Answers (1)

Gaël Marziou
Gaël Marziou

Reputation: 16284

JHipster requires that all your entities are defined in one single JDL file. If you haven't saved the definition of your previous entities you can export them using jhipster export-jdl app.jh then edit app.jh to add your new entity and re-import using jhipster import-jdl app.jh

Upvotes: 4

Related Questions