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.58k stars 4.02k forks source link

Relationship built failed by `Authority with builtInEntity` #27825

Open flyliu33 opened 2 weeks ago

flyliu33 commented 2 weeks ago
Overview of the issue

1. errors in relationships I tried to add a relationship between Authority entity and other custom entity as similar as User entity, but failed. I added the following code in my jdl file.

relationship OneToOne {
    Customer{user(login) required} to User with builtInEntity
  Customer{authority(name) required} to Authority with builtInEntity
}

OR

relationship ManyToOne {
  Customer{authority(name) required} to Authority with builtInEntity
}

It seemed to miss some code. image

2. errors in dto While adding the Customer entity with dto together, another errors arose during genereting a new project errors.txt

Motivation for or Use Case

Adding new columns in Authority entity and associated relationships with Authority, because the basic feature of current authority cannot support the advanced authority management features.

Reproduce the error
  1. execute jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --auto-crlf
  2. it will show error in ide after compiled as error 1.
  3. uncomment dto * with mapstruct in jdl, execute jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --auto-crlf in another new directory
  4. it will show error in the terminal as error 2.
Related issues
Suggest a Fix
JHipster Version(s)

8.7.3

JHipster configuration

Jdl file: microservice-ecommerce-store-4-apps.txt

    ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
    ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
    ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝

██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║ ╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗ ╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝ https://www.jhipster.tech Welcome to JHipster v8.7.3

Welcome to the JHipster Information Sub-Generator

store@0.0.0 D:\workspace\test\jhipster\ms-ecommerce-store\store
`-- generator-jhipster@8.7.3
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationIndex": 0,
    "applicationType": "gateway",
    "applications": {
      "invoice": {
        "applicationIndex": 2,
        "serverPort": "8082"
      },
      "notification": {
        "applicationIndex": 3,
        "serverPort": "8083"
      },
      "product": {
        "applicationIndex": 1,
        "serverPort": "8081"
      }
    },
    "authenticationType": "jwt",
    "autoCrlf": true,
    "baseName": "store",
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "vue",
    "devServerPort": 9060,
    "entities": [
      "Customer",
      "Product",
      "ProductCategory",
      "ProductOrder",
      "OrderItem",
      "Invoice",
      "Shipment",
      "Notification"
    ],
    "jhipsterVersion": "8.7.3",
    "languages": [
      "en"
    ],
}
Environment and Tools

openjdk version "17.0.12" 2024-07-16 LTS OpenJDK Runtime Environment Corretto-17.0.12.7.1 (build 17.0.12+7-LTS) OpenJDK 64-Bit Server VM Corretto-17.0.12.7.1 (build 17.0.12+7-LTS, mixed mode, sharing)

git version 2.45.1.windows.1

node: v20.17.0 npm: 10.8.2

Docker version 27.1.1, build 6312585

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
@ChangelogDate("20241106034019")
entity Customer {
  firstName String required
  lastName String required
  gender Gender required
  email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
  phone String required
  addressLine1 String required
  addressLine2 String
  city String required
  state String
  country String required
}
/**
 * Product sold by the Online store
 */
@ChangelogDate("20241106034119")
entity Product {
  name String required
  description String
  price BigDecimal required min(0)
  productSize Size required
  comment String
  image ImageBlob
}
@ChangelogDate("20241106034219")
entity ProductCategory {
  name String required
  description String
}
@ChangelogDate("20241106034319")
entity ProductOrder {
  placedDate Instant required
  status OrderStatus required
  code String required
  invoiceId Long
  customer String required
}
@ChangelogDate("20241106034419")
entity OrderItem {
  quantity Integer required min(0)
  totalPrice BigDecimal required min(0)
  status OrderItemStatus required
}
@ChangelogDate("20241106034519")
entity Invoice {
  code String required
  date Instant required
  details String
  status InvoiceStatus required
  paymentMethod PaymentMethod required
  paymentDate Instant required
  paymentAmount BigDecimal required
}
@ChangelogDate("20241106034619")
entity Shipment {
  trackingCode String
  date Instant required
  details String
}
@ChangelogDate("20241106034719")
entity Notification {
  date Instant required
  details String
  sentDate Instant required
  format NotificationType required
  userId Long required
  productId Long required
}

enum Gender {
  MALE,
  FEMALE,
  OTHER
}
enum Size {
  S,
  M,
  L,
  XL,
  XXL
}
enum OrderStatus {
  COMPLETED,
  PENDING,
  CANCELLED
}
enum OrderItemStatus {
  AVAILABLE,
  OUT_OF_STOCK,
  BACK_ORDER
}
enum InvoiceStatus {
  PAID,
  ISSUED,
  CANCELLED
}
enum PaymentMethod {
  CREDIT_CARD,
  CASH_ON_DELIVERY,
  PAYPAL
}
enum NotificationType {
  EMAIL,
  SMS,
  PARCEL
}

relationship OneToOne {
  Customer{user(login) required} to User with builtInEntity
  Customer{authority(name) required} to Authority with builtInEntity
}
relationship OneToMany {
  ProductCategory{product} to Product{productCategory(name)}
  ProductOrder{orderItem} to OrderItem{order(code) required}
  Invoice{shipment} to Shipment{invoice(code) required}
}
relationship ManyToOne {
  OrderItem{product(name) required} to Product
}

paginate Customer, Product, ProductOrder, OrderItem, Invoice, Shipment with pagination
service Customer, Product, ProductCategory, ProductOrder, OrderItem, Invoice, Shipment with serviceClass
search Customer, Product, ProductCategory, ProductOrder, OrderItem, Invoice, Shipment, Notification with no
microservice Product, ProductCategory, ProductOrder, OrderItem with product
microservice Invoice, Shipment with invoice
microservice Notification with notification
clientRootFolder Product, ProductCategory, ProductOrder, OrderItem with product
clientRootFolder Invoice, Shipment with invoice
clientRootFolder Notification with notification

Congratulations, JHipster execution is complete! If you find JHipster useful consider sponsoring the project https://www.jhipster.tech/sponsors/

Thanks for using JHipster!

Browsers and Operating System

Edition Windows 11 Pro Version 23H2 Installed on ‎8/‎19/‎2024 OS build 22631.4391 Experience Windows Feature Experience Pack 1000.22700.1047.0

github-actions[bot] commented 2 weeks ago

JHipster has completed the sample check .yo-rc.json: error Entities JDL: valid Application: Frontend check: skipped Backend check: skipped E2E check: skipped

This check uses jhipster info output from the issue description to generate the sample. Bug report that does not contain this information will be marked as invalid.

mshima commented 2 weeks ago

The provided reproduction is invalid cannot be tested by CI. Authority relationship is currently tested in imperative sql only.

flyliu33 commented 2 weeks ago

The provided reproduction is invalid cannot be tested by CI. Authority relationship is currently tested in imperative sql only.

  1. Can you explain more details why it was invalid? It can work on my PC environment and then the error will arise.
  2. So, Authority relation in jdl doesn't support to use in practice yet?
flyliu33 commented 2 weeks ago

I also found issues of the many to many relationship in regular entities. There is a many-to-many relationship between Employee and Company in the following jdl file excluding any authority relevant definition. microservice-ecommerce-store-4-apps.txt

Reproduction step:

  1. execute jhipster jdl .\microservice-ecommerce-store-4-apps.jdl --auto-crlf
  2. run store getaway service.
  3. adding and saving an entity with Company item in Employee feature, then error alert will arise on the web page. image

image

  1. editing and saving an entity with Company item in Employee feature, though no errors arose, Company data can upload to backend successfully, but still cannot store in database.

BTW, I found the reactive services including gateway cannot output the logs of uncatching exceptions on IDE console as non-reactive microservices did.