0

There are two tables Period_Type & Product_Subscription

Period_Type 
->ID
->Period_Type_Name
---------------------------------------
Product_Subscription
-> RENEWAL_PERIOD_TYPE_ID
-> SUBSCRIPTION_PERIOD_TYPE_ID
----------------------------------------
-> FOREIGN KEY (RENEWAL_PERIOD_TYPE_ID) REFERENCES PERIOD_TYPE(ID)
-> FOREIGN KEY (SUBSCRIPTION_PERIOD_TYPE_ID) REFERENCES PERIOD_TYPE(ID)

How to implement the above schema using JDL?

Gaël Marziou
  • 16,028
  • 4
  • 38
  • 49

1 Answers1

0

Please read the doc: https://www.jhipster.tech/jdl/relationships about JDL syntax and also there is an example which is exactly your use case: https://www.jhipster.tech/managing-relationships/#two-one-to-many-relationships-on-the-same-two-entities

You must indicate the relationship name in the relationship definition so that it is used for both the entity's field for the name of the foreign key in Liquibase changelog.

entity PeriodType {
    periodTypeName String
}

entity ProductSubscription {
}

relationship ManyToOne {
    ProductSubscription{renewalPeriodType} to PeriodType
    ProductSubscription{subscriptionPeriodType} to PeriodType
}

Additionally, you can also specify which field to use for display in frontend.

Gaël Marziou
  • 16,028
  • 4
  • 38
  • 49
  • ERROR! Error at entity ProductSubscription: relationship name is not synchronized – Utkarsh Srivastava Jan 05 '23 at 07:09
  • ProductSubscription { subscriptionPeriodType(periodTypeName)} to PeriodType {productSubscription(moduleFuncDescription)}, ProductSubscription { renewalPeriodType(periodTypeName)} to PeriodType {productSubscription(moduleFuncDescription)} --> wrote like this, still facing same errors==>Error running generator entities: Error: Error at entity ProductSubscription: relationship name is not synchronized – Utkarsh Srivastava Jan 05 '23 at 11:13
  • My JDL is working I tested it,. If you changed it and it's no longer working : please accept my answer and open a new question with new problem showing code and giving context. – Gaël Marziou Jan 05 '23 at 11:45