Generator-jhipster: [jdl] Change jdl annotations.

Created on 3 Nov 2020  路  8Comments  路  Source: jhipster/generator-jhipster

Overview of the feature request
  • Change jdl annotations to set lowerFirst option:
entity A {
  @Id Long customId
}

Should set id option to true instead of Id.

  • Change relationship annotation to don't create options in the other side.
application {entities *} entity A{} entity B{} relationship OneToOne { @id A to B }

Currently generates:

{
  "name": "A",
  "relationships": [
    {
      "relationshipType": "one-to-one",
      "otherEntityName": "b",
      "otherEntityRelationshipName": "a",
      "relationshipName": "b",
      "otherEntityField": "id",
      "ownerSide": true,
      "options": {
        "id": true
      }
    }
  ],
...
}
{
  "name": "B",
  "relationships": [
    {
      "relationshipType": "one-to-one",
      "otherEntityName": "a",
      "otherEntityRelationshipName": "b",
      "relationshipName": "a",
      "otherEntityField": "id",
      "ownerSide": false,
      "options": {
        "id": true
      }
    }
  ],
...
}

Makes harder to detect if A is id of B or if B is id of A.

A solution is to allow annotations on other side:
relationship OneToOne { A to @id B }

Motivation for or Use Case
Related issues or PR
  • [ ] Checking this box is mandatory (this is just to show you read everything)
area JDL v7

All 8 comments

cc @MathieuAA

I'm taking this one

This is a jdl breaking change.
Needs to be implemented before v7.

Indeed @mshima. For the first issue, this involves every option. Plus, I don't see why options beginning by an upper-case letter should be allowed. I propose to only allow options beginning with a lowercase letter. @mshima WDYT?

For the second issue, thanks for the examples. I'm fixing it.

For the first issue, this involves every option. Plus, I don't see why options beginning by an upper-case letter should be allowed. I propose to only allow options beginning with a lowercase letter.

I prefer upper case, I think it鈥檚 prettier and AFAIK most of languages uses upper case annotations.
Any approach fixes the issue 馃槃 .

For the second issue, thanks for the examples. I'm fixing it.

Great thanks.

@pascalgrimaud this change is a breaking change.
IMO can be done after first beta, but should be resolved before final.

Annotations for relationship should be inverted IMO.
OneToOne { @id A to B }

Should generate:

{
  "name": "A",
  "relationships": [
    {
      "relationshipType": "one-to-one",
      "otherEntityName": "b",
      "otherEntityRelationshipName": "a",
      "relationshipName": "b",
      "otherEntityField": "id",
      "ownerSide": true
    }
  ],
...
}
{
  "name": "B",
  "relationships": [
    {
      "relationshipType": "one-to-one",
      "otherEntityName": "a",
      "otherEntityRelationshipName": "b",
      "relationshipName": "a",
      "otherEntityField": "id",
      "ownerSide": false,
      "options": {
        "id": true
      }
    }
  ],
...
}

Meaning A is an id for B
Just like OneToOne { B to @id A }
Makes more sense for me.

Agreed, it's already taken care of BTW :)
Thanks Marcelo

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcelinobadin picture marcelinobadin  路  3Comments

ahmedeldeeb25 picture ahmedeldeeb25  路  3Comments

DanielFran picture DanielFran  路  3Comments

SudharakaP picture SudharakaP  路  3Comments

dronavallisaikrishna picture dronavallisaikrishna  路  3Comments