JHipster为什么说未声明我的实体? [英] Why does JHipster say that my entity is not declared?

查看:62
本文介绍了JHipster为什么说未声明我的实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在file1.jdl中,我具有实体X定义,并且import-jdl正确生成了它,并且可以在.jhipster/X.json中看到它

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

在file2.jdl中,我有这种关系:

In file2.jdl I have this relationship:

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

当我尝试在file2.jdl上导入jdl时,它给了我这个错误:

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

从JDL解析应用程序和实体时出错:在X和X之间的关系中,未声明X和X.

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

推荐答案

我想这是由于您定义了双向自我关系,似乎您正在建模树或某种层次结构.

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.

如果您使用SQL进行操作,我怀疑这会在遍历树时导致性能问题.如果搜索如何用SQL表示树",您会发现这是一个经典问题,并且取决于所使用的数据库引擎,您甚至可能会找到管理它的特定结构.您还可以搜索如何在JPA中表示树".

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".

您是否曾尝试将其简化为"X {subordinateX}到X"以避免双向传播?

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

因此,它可能是JHipster中的错误,但可能很难修复,因为它在UI中有很多含义.随时在github上报告它,也许其他人会提出修复.

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.

作为一种解决方法,您可以尝试创建一个外部实体,以实现只有两个从属和上级列的层次关系(SQL中的一种联接表).

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.

这篇关于JHipster为什么说未声明我的实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆