0

I created application with the following jdl.

And then, I ran the test with cypress when it was created successfully. Most of them pass but get some errors in entities that have relationship with User entity in microservice.

I noticed that the application does not automatically add user information to the microservices' databases. This is unlike any other I have done before. I tried removing the kafka option but the result is the same.

Tell me, is my design wrong? Please

Thanks very much

application {
  config {
    baseName StudySpace
    applicationType gateway
    packageName io.witcher.studyspace
    serverPort 8080
    authenticationType oauth2
    databaseType sql
    devDatabaseType mysql
    prodDatabaseType mysql
    cacheProvider hazelcast
    clientFramework react
    buildTool gradle
    languages [vi, en]
    clientTheme flatly
    serviceDiscoveryType consul
    testFrameworks [cypress]
    messageBroker kafka
  }
  entities *
}

application {
  config {
    baseName GroupService
    applicationType microservice
    packageName io.witcher.studyspace.group_service
    serverPort 8081
    authenticationType oauth2
    databaseType sql
    devDatabaseType mysql
    prodDatabaseType mysql
    buildTool gradle
    languages [en, vi]
    cacheProvider hazelcast
    serviceDiscoveryType consul
    testFrameworks [cypress]
    messageBroker kafka
  }
  entities Group, GroupMember, GroupAdmin, WaitingMember
}

application {
  config {
    baseName ExamStore
    applicationType microservice
    packageName io.witcher.studyspace.exam_store
    serverPort 8082
    authenticationType oauth2
    databaseType sql
    devDatabaseType mysql
    prodDatabaseType mysql
    buildTool gradle
    languages [en, vi]
    cacheProvider hazelcast
    serviceDiscoveryType consul
    testFrameworks [cypress]
    messageBroker kafka
  }
  
  entities Topic, Exam, ExamItem, Question, Option, QuestionGroup
 }

application {
  config {
    baseName AnswerStore
    reactive true
    applicationType microservice
    packageName io.witcher.studyspace.answer_store
    serverPort 8083
    authenticationType oauth2
    databaseType sql
    devDatabaseType mysql
    prodDatabaseType mysql
    buildTool gradle
    languages [en, vi]
    cacheProvider hazelcast
    serviceDiscoveryType consul
    testFrameworks [cypress]
    messageBroker kafka
  }
  entities GroupTimeTable, TimeTable, AnswerSheet, AnswerSheetItem
}

entity GroupAdmin {}

entity WaitingMember {}

entity GroupMember {}

entity Group {
    groupId String unique required
  name String minlength(5) maxlength(255) required
}

entity Topic {
    topicId String unique required
  name String minlength(5) maxlength(255) required
}

entity QuestionGroup {
    repoId String unique required
  name String minlength(5) maxlength(255) required
  groupId String
}

entity Question {
    content TextBlob required
    note TextBlob
}

entity Option {
    content TextBlob required
  isCorrect Boolean required
}

entity Exam {
    examId String unique required
  name String minlength(3) maxlength(155) required
  duration Integer min(5) max(180) required
  mix Integer min(0) max(2) required 
    groupId String required
}

entity ExamItem {
    numOfQuestion Integer required
}

entity GroupTimeTable {
    examId String required
  startAt Instant required
  endAt Instant required
  groupId String required
  note String
}

entity TimeTable {
    title String minlength(2) maxlength(255)
  time Instant
  note TextBlob required
}

entity AnswerSheet {
    time Instant required
}

entity AnswerSheetItem {
    questionId Integer required
  answerId Integer required
}

relationship ManyToOne {
  GroupMember{user(login)} to User
  GroupMember{group(groupId)} to Group
  
  WaitingMember{user(login)} to User
  WaitingMember{group(groupId)} to Group
  
  GroupAdmin{user(login)} to User
  GroupAdmin{group(groupId)} to Group

    AnswerSheet{groupTimeTable} to GroupTimeTable
  AnswerSheet{user(login)} to User

  TimeTable{user(login)} to User
  AnswerSheetItem{answerSheet} to AnswerSheet
  
  QuestionGroup{user(login)} to User
  QuestionGroup{topic(topicId)} to Topic
  
  Question{repo(repoId)} to QuestionGroup
  Option{question} to Question
  
  ExamItem{repo} to QuestionGroup
  ExamItem{exam} to Exam
}

dto * with mapstruct
service * with serviceClass
paginate * with infinite-scroll

microservice Group, GroupMember, GroupAdmin, WaitingMember with GroupService
microservice Topic, Exam, ExamItem, Question, Option, QuestionGroup with ExamStore
microservice GroupTimeTable, TimeTable, AnswerSheet, AnswerSheetItem with AnswerStore

loc.dang
  • 374
  • 3
  • 19
  • It's because you use DTOs, see my answer to https://stackoverflow.com/questions/68451382/jhipster-7-1-0-failed-to-use-jdl-import-throws-error-looking-for-otherentity-u – Gaël Marziou Aug 21 '21 at 21:11
  • Thanks @GaëlMarziou , I understand – loc.dang Aug 22 '21 at 06:00
  • @GaëlMarziou I tried removing the `DTO option` but it still not auto add user data into `AnswerService's database` – loc.dang Aug 22 '21 at 09:48
  • Have you started from a fresh empty directory? Unfortunately, this feature is half complete and has drawbacks, I'm not sure why people wants to use it, to me it goes against microservices principles. – Gaël Marziou Aug 22 '21 at 13:44
  • Thank @GaëlMarziou, I'm sure I created it in empty folder. I think it's simpler especially for newbies like me. Right now, I'm going to use `user.login` connect to user related tables. I can get current user login with `SecutityUtils.getCurrentUserLogin()` so I will skip user-management in my microservice. – loc.dang Aug 23 '21 at 07:07

0 Answers0