gpt4 book ai didi

java - 在Jhipster中使用JDL时出错

转载 作者:行者123 更新时间:2023-11-30 02:45:41 28 4
gpt4 key购买 nike

我在 Jhipster 中使用 JDL 时遇到问题。我使用 JDL-Studio 设计我的实体,这是创建后的 jhipster-jdl.jh 文件:

    entity Member {
fullName String required maxlength(100),
birthDay LocalDate,
address String maxlength(100),
phone String maxlength(12),
avatar String maxlength(100),
aboutMe String maxlength(5000),
systemStatus SystemStatus required,
star Integer required
}

entity RealEstate {
useFor UseFor required,
location String maxlength(100),
address String required maxlength(100),
acreage Float required,
price Float required,
currencyUnit CurrencyUnit required,
typeRent TypeRent,
status Status required,
systemStatus SystemStatus required,
description String maxlength(7000),
star Integer required,
numberBedRooms Integer,
numberBathRooms Integer,
avatar String maxlength(100)
buildIn LocalDate,
numberViews Integer required,
createDate ZonedDateTime required
}

entity TypeRealEstate {
name String required maxlength(50),
number Integer required
}

entity Project {
name String required maxlength(100),
address String maxlength(100),
location String maxlength(100),
avatar String maxlength(100),
price Float,
description String maxlength(10000)
tag String maxlength(200)
}

entity TypeProject {
name String required maxlength(50)
number String required
}

entity Coordinate {
lat Float required,
lnt Float required,
type TypeCoordinate required
}

entity Bounds {

}

entity Question {
content String required maxlength(1000)
timeQuestion ZonedDateTime required,
answer String required maxlength(1000),
timeAnswer ZonedDateTime required,
levelOfSatisfaction Float min(0) max(5)
}

entity Tag {
name String required maxlength(50),
number Integer required
}


entity Notification {
content String required maxlength(100),
typeNoti TypeNoti required
}

enum UseFor {
SALE, RENT
}

enum CurrencyUnit {
MILLION, BILLION
}

enum TypeRent {
MONTH, YEAR
}

enum Status {
AVAILABLE, NOT_AVAILABLE
}

enum SystemStatus {
PENDING, APPROVED, NOT_APPROVE, LOCKED
}

enum TypeCoordinate {
REAL_ESTATE, PROJECT, BOUNDS
}

enum TypeNoti {
ANSWER, QUESTION, STAR
}

relationship OneToOne {
Member{user} to User
}


relationship OneToMany {
Member{realEstate} to RealEstate{poster}
}

relationship OneToMany {
Project{realEstate} to RealEstate{project}
}

relationship OneToOne {
Coordinate{project} to Project{coordinate}
}

relationship OneToOne {
Coordinate{realEstate} to RealEstate{coordinate}
}

relationship ManyToMany {
Member{userStar} to User
}

relationship OneToMany {
RealEstate{question} to Question
}

relationship OneToMany {
Project{question} to Question
}

relationship OneToOne {
Question{user} to User
}

relationship OneToOne {
Bounds{southWest} to Coordinate
}

relationship OneToOne {
Bounds{northEast} to Coordinate
}

relationship OneToOne {
RealEstate{bounds} to Bounds
}

relationship OneToOne {
Project{bounds} to Bounds
}

relationship ManyToOne {
Notification{user} to User
}

relationship OneToOne {
Notification{question} to Question
}

relationship OneToOne {
Notification{realEstate} to RealEstate
}

relationship OneToOne {
Notification{project} to Project
}

relationship ManyToMany {
RealEstate{userStar} to User
}

relationship ManyToMany {
RealEstate{tag} to Tag{realEstate}
}

relationship ManyToMany {
Project{tag} to Tag{project}
}

relationship OneToMany {
TypeRealEstate{realEstate} to RealEstate{type}
}

relationship OneToMany {
TypeProject{project} to Project{type}
}

paginate RealEstate, Member, Project, Question, Notification with infinite-scroll

dto * with mapstruct

然后我使用命令 yo jhipster:import-jdl jhipster-jdl.jh 生成实体,它运行成功,没有任何错误。但是当我使用命令 ./mvnw 运行我的项目时,我的项目无法运行,这是日志:

2016-10-27 09:18:31.099 ERROR 8835 --- [  restartedMain] o.h.hql.internal.ast.ErrorCounter        : line 1:17: unexpected token: member
2016-10-27 09:18:31.103 ERROR 8835 --- [ restartedMain] o.h.hql.internal.ast.ErrorCounter : line 1:17: unexpected token: member

antlr.NoViableAltException: unexpected token: member
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectClause(HqlBaseParser.java:1343)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1062)
at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:731)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:323)
at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:186)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:295)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:131)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1836)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:109)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:304)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:131)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1836)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328)
... 53 common frames omitted

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.009 s
[INFO] Finished at: 2016-10-27T09:18:32+07:00
[INFO] Final Memory: 65M/527M
[INFO] -----------------------------------------------------------------------

我正在使用 Mariadb。我不知道发生了什么,请帮助我!谢谢大家

最佳答案

如果您运行 Maven 测试,您可以看到以下内容:

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: member near line 1, column 17 [select distinct member from com.mycompany.myapp.domain.Member member left join fetch member.userStars]

这是因为 Member 是 JPQL 中的保留字(MEMBER OF 表达式)。

只需更改成员实体的名称即可。

关于java - 在Jhipster中使用JDL时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40275667/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com