jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

Microservice Entity #18819

Closed paris0120 closed 2 years ago

paris0120 commented 2 years ago
Overview of the issue

Based on https://www.jhipster.tech/user-entity/ and https://www.jhipster.tech/creating-microservices/#generating_entities, microservice with oauth2 should include a User class. However, when I try to include user in a relationship, I got ERROR! Error during import-jdl: The entity User which is declared in forum's entity list doesn't exist.

Motivation for or Use Case
Reproduce the error

jhipster jdl the following .jdl file

application { config { baseName forum, applicationType microservice, packageName com.spring.microservice, authenticationType oauth2, prodDatabaseType mysql, devDatabaseType h2Disk, reactive true, serviceDiscoveryType eureka } entities Category, Topic, Comment, User }

entity Category { name String required, description String required, created Long required, modified Long required, deleted Long
}

entity Topic { title String required, content String required, created Long required, modified Long required, deleted Long
}

entity Comment { content String required, created Long required, modified Long required, deleted Long }

relationship OneToMany { Category to Topic{category}, Category to Category{parentCategory}, Topic to Comment{topic}, Comment to Comment{parent}, }

relationship ManyToOne { Category{user} to User, Topic{user} to User, Comment{user} to User,

}

Related issues
Suggest a Fix
JHipster Version(s)
JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
mraible commented 2 years ago

You might need to add this at the bottom:

microservice Category, Topic, Comment, User with forum

That's the only difference I see between your JDL and reactive-ms.jdl.

paris0120 commented 2 years ago

You might need to add this at the bottom:

microservice Category, Topic, Comment, User with forum

That's the only difference I see between your JDL and reactive-ms.jdl.

Thank you for the quick reply. I checked with https://github.com/jhipster/jdl-samples/blob/master/microservices-blog-store.jh and find that I shouldn't include User in the entity.

paris0120 commented 2 years ago

You might need to add this at the bottom:

microservice Category, Topic, Comment, User with forum

That's the only difference I see between your JDL and reactive-ms.jdl.

Sorry for bothering you again but I keep getting

WARNING! Error at 'Category' definitions: 'otherEntityRelationshipName' is set with value 'category' at relationship 'user' but no back-reference was found at 'user'

Since User is managed by jhipster, how to fix the Error?

Again thank you for your time.

mraible commented 2 years ago

That's just a warning. I believe @mshima added it. Everything still works fine in my experience.

paris0120 commented 2 years ago

That's just a warning. I believe @mshima added it. Everything still works fine in my experience.

Thank you.

mshima commented 2 years ago

Sorry for bothering you again but I keep getting

WARNING! Error at 'Category' definitions: 'otherEntityRelationshipName' is set with value 'category' at relationship 'user' but no back-reference was found at 'user'

should be fixed in main

Tcharl commented 2 years ago

Could this 'microservice' option be renamed on v8? first, it should be an 'application' option for types 'gateway' instead of a generic option, then this 'microservice' keyword is not that self-explanatory, 'routed' or 'proxied'

DanielFran commented 2 years ago

Closing, since doubts have been answered