Boris Šipoš
Boris Šipoš

Reputation: 61

Why does JHipster say that my entity is not declared?

In file1.jdl I have entity X definition and import-jdl generated it correctly, and can see it in .jhipster/X.json

In file2.jdl I have this relationship:

relationship OneToMany{
    X{subordinateX} to X{superiorX}
}

When I try to import-jdl on file2.jdl it gives me this error:

Error while parsing applications and entities from the JDL Error: In the relationship between X and X, X and X are not declared.

Is this an issue or I did something wrong?

Thx

Upvotes: 2

Views: 631

Answers (1)

Gaël Marziou
Gaël Marziou

Reputation: 16284

I guess this is due to the fact that you define a bidirectional self relationship, it seems you're modeling a tree or a hierarchy of some kind.

If you were doing it in SQL, I suspect that this would lead to performance problems when traversing the tree. If you search for "How to represent a tree in SQL" you will find that it's a classic problem and depending on which database engine you use, you may even find a specific structure to manage it. You can search also for "How to represent a tree in JPA".

Have you tried simplifying it like "X{subordinateX} to X" to avoid being bidirectional?

So, it's probably a bug in JHipster but it could be hard to fix because it has many implications in UI for instance. Feel free to report it on github, maybe someone else will propose a fix.

As a workaround, you could try to create an external entity to materialize this hierarchical relationship (a kind of join table in SQL) with only 2 columns subordinate and superior.

Upvotes: 1

Related Questions