问题描述
我在 Jhipster 中使用 JDL 时遇到问题.我用 JDL-Studio 设计我的实体,这是创建后的 jhipster-jdl.jh 文件:
I have a problem when use JDL in Jhipster. I design my entities with JDL-Studio, this is jhipster-jdl.jh file after created:
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
运行我的项目时,我的项目无法运行,这是日志:
And then I use command yo jhipster:import-jdl jhipster-jdl.jh
to generator the entities and it run success, nothing error. But when I run my project with command ./mvnw
then my project can't run, this is log:
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.不知道怎么回事,求大神帮忙!谢谢大家
I'm using Mariadb. I don't know what going on, please help me! Thank everyone
推荐答案
如果你运行 Maven 测试你可以看到:
If you run Maven test you can see this :
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 表达式).
This is because Member is a reserved word in JPQL (the MEMBER OF expression).
只需更改成员实体的名称即可.
Just change the name of the Member entity and it should work.
这篇关于在 Jhipster 中使用 JDL 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!