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

@embedded throw a Cannot read properties of undefined (reading 'name') #18082

Closed tiboun closed 2 years ago

tiboun commented 2 years ago
Overview of the issue

Using the following jdl, I encounter an issue regarding embedded document. If I remove the annotation then the generation works fine.

`application { config { baseName myapp, applicationType monolith, packageName com.test.myapp, authenticationType jwt, databaseType mongodb, clientFramework vue, buildTool maven, clientPackageManager npm, clientTheme united, clientThemeVariant primary, dtoSuffix DTO, enableSwaggerCodegen true, enableTranslation true, languages [en, nl, fr, de, it, es], nativeLanguage en, reactive true, serverPort 8080, searchEngine false, enableSwaggerCodegen true, testFrameworks [cypress, gatling] } entities dto with mapstruct service with serviceClass paginate with pagination }

entity Country { countryName String }

@embedded entity Region { regionName String }

relationship OneToOne { Country to Region }`

Motivation for or Use Case

I want to embedded the document as specified in the official documentation.

Reproduce the error

Just try to generate with jhipster jdl ./test.jdl

Related issues

Not found in issues.

Suggest a Fix

I'm a new user of Jhipster (didn't have the opportunity to use this tool before) but when embedded, I don't know why we go into the processEagerLoadRelationships method since with MongoDB it will but a nested document with all its information in their but maybe in Jhipster generation process, the meaning is different and having a nested document is similar to eagerly load it for generation purpose.

JHipster Version(s)

7.7.0

JHipster configuration

Welcome to JHipster v7.7.0

Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
rdv@0.0.0 /home/tiboun/projects/real-time-digital-vision
└── generator-jhipster@7.7.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationIndex": 0,
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "myapp",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "vue",
    "clientPackageManager": "npm",
    "clientTheme": "united",
    "clientThemeVariant": "primary",
    "creationTimestamp": 1646737679508,
    "databaseType": "mongodb",
    "devDatabaseType": "mongodb",
    "devServerPort": 9060,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": true,
    "enableTranslation": true,
    "entities": [],
    "entitySuffix": "",
    "gradleEnterpriseHost": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.7.0",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en", "nl", "fr", "de", "it", "es"],
    "lastLiquibaseTimestamp": 1646933208000,
    "messageBroker": false,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageFolder": "com/tests/myapp",
    "packageName": "com.tests.myapp",
    "pages": [],
    "prodDatabaseType": "mongodb",
    "reactive": true,
    "searchEngine": false,
    "serverPort": "8080",
    "serverSideOptions": ["enableSwaggerCodegen:true"],
    "serviceDiscoveryType": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "skipUserManagement": false,
    "testFrameworks": ["cypress", "gatling"],
    "websocket": false,
    "withAdminUi": true
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04) OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

git version 2.25.1

node: v16.14.0

npm: 8.5.3

Docker version 20.10.9, build c2ea9bc

Docker Compose version v2.2.3

`application { config { baseName rdv, applicationType monolith, packageName com.rcibs.rdv, authenticationType jwt, databaseType mongodb, clientFramework vue, buildTool maven, clientPackageManager npm, clientTheme united, clientThemeVariant primary, dtoSuffix DTO, enableSwaggerCodegen true, enableTranslation true, languages [en, nl, fr, de, it, es], nativeLanguage en, reactive true, serverPort 8080, searchEngine false, enableSwaggerCodegen true, testFrameworks [cypress, gatling] } entities dto with mapstruct service with serviceClass paginate with pagination }

entity Country { countryName String }

@embedded entity Region { regionName String }

relationship OneToOne { Country to Region }`

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

None it's the beginning of the project.

Browsers and Operating System

Not related

mshima commented 2 years ago

Duplicate of https://github.com/jhipster/generator-jhipster/issues/18017.