jhipster / jhipster-core

JHipster Domain Language, used by JHipster UML and JDL-Studio to generate entities
Apache License 2.0
346 stars 116 forks source link

option jpaDerivedIdentifier in JDL is ignored #388

Closed standors closed 4 years ago

standors commented 4 years ago
Overview of the issue

imported JDL OneToOne relation contains jpaDerivedIdentifier -> the code generated is exactly as without this option (without @MapsId)

Motivation for or Use Case
Reproduce the error

import JDL and check code of UserInfo

Related issues
Suggest a Fix

in previous Jhipster version 6.2.0 this worked OK. problem is that generated .jhipster/UserInfo.json syntax changed for jpaDerivedIdentifier in comparision with JH 6.2.0 in JH 6.4.1. "relationships": [ { "relationshipType": "one-to-one", "otherEntityName": "user", "otherEntityRelationshipName": "userInfo", "relationshipName": "user", "otherEntityField": "id", "ownerSide": true, "options" { "useJPADerivedIdentifier": true } }

in JH 6.2.0: "relationships": [ { "relationshipType": "one-to-one", "otherEntityName": "user", "otherEntityRelationshipName": "userInfo", "relationshipName": "user", "otherEntityField": "id", "ownerSide": true, "useJPADerivedIdentifier": true }

the new syntax uses 'options' block. if I manually change UserInfo.json as was in ver. Jh 6.2.0
and run jhipster --with-entities
then the generated code for UserInfo is correct

INFO! Using JHipster version installed locally in current project's node_modules INFO! Executing jhipster:info INFO! Options: from-cli: true

JHipster Version(s)
wgapi@0.0.1-SNAPSHOT /home/ogl/src/gis/wgapi-mmba-jh
└── generator-jhipster@6.4.1 
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "wg",
      "nativeLanguage": "sk"
    },
    "jhipsterVersion": "6.4.1",
    "applicationType": "monolith",
    "baseName": "wgapi",
    "packageName": "wg",
    "packageFolder": "wg",
    "serverPort": "8080",
    "authenticationType": "oauth2",
    "cacheProvider": "hazelcast",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "prodDatabaseType": "postgresql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "react",
    "clientTheme": "flatly",
    "clientThemeVariant": "primary",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": true,
    "nativeLanguage": "sk",
    "languages": ["sk"],
    "blueprints": [],
    "embeddableLaunchScript": false
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity UserInfo (wg_tuser_info) {
  authKey String
}
relationship OneToOne {
 UserInfo{user} to User with jpaDerivedIdentifier
}

paginate UserInfo with pagination
service  UserInfo with serviceClass
filter  UserInfo

Environment and Tools

openjdk version "11.0.3" 2019-04-16 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)

git version 2.20.1

node: v12.7.0

npm: 6.10.2

yeoman: 3.1.0

yarn: 1.12.3

Docker version 18.09.6, build 481bc77

docker-compose version 1.22.0, build f46880fe

INFO! Congratulations, JHipster execution is complete!

Entity configuration(s) entityName.json files generated in the .jhipster directory

UserInfo.json { "name": "UserInfo", "fields": [ { "fieldName": "authKey", "fieldType": "String" } ], "relationships": [ { "relationshipType": "one-to-one", "otherEntityName": "user", "otherEntityRelationshipName": "userInfo", "relationshipName": "user", "otherEntityField": "id", "ownerSide": true, "options" { "useJPADerivedIdentifier": true } } ], "changelogDate": "20191007100542", "entityTableName": "wg_tuser_info", "dto": "no", "pagination": "pagination", "service": "serviceClass", "jpaMetamodelFiltering": true, "fluentMethods": true, "clientRootFolder": "", "applications": "*", "readOnly": false }

Browsers and Operating System
MathieuAA commented 4 years ago

I'm transferring this issue to investigate it

MathieuAA commented 4 years ago

Thanks for reporting this one! when parsing the option, the value set internally was wrong. I'm fixing it right now