Generator-jhipster: invalid otherEntityRelationshipName when importing JDL

Created on 5 Feb 2019  路  4Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

Hi,
I was using the generator to create the entities from an import file (.jh https://github.com/Tonterias/jhipsterpress/blob/3b05474a7810680a0c33844ef54f5bfec5648a3b/src/main/scripts/jhp.jh) and it creates code that shows errors. Here is the code generated with version 5.8.1

Line 81: uprofile.getActivity(activityName)S().add(this);
Correct Line 86: uprofile.getActivities().add(this);

(https://github.com/Tonterias/jhipsterpress/blob/3b05474a7810680a0c33844ef54f5bfec5648a3b/src/main/java/com/jhipsterpress/web/domain/Activity.java) and here is the correct code created with an older version: (https://github.com/Tonterias/jhipsterpress09/blob/master/src/main/java/com/jhipsterpress/web/domain/Activity.java) Line 86

Motivation for or Use Case

The code is not correct

Reproduce the error

jhipster import-jdl ./src/main/scripts/jhp.jh

Related issues

Errors in tests

Suggest a Fix

Sorry, no idea

JHipster Version(s)

v5.8.1

JHipster configuration

N/A

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

8 Entities: https://github.com/Tonterias/jhipsterpress/blob/3b05474a7810680a0c33844ef54f5bfec5648a3b/src/main/scripts/jhp.jh

Browsers and Operating System

Any

  • [X] Checking this box is mandatory (this is just to show you read everything)
area JDL

Most helpful comment

So I found the bug and submitted a PR that fixes it at the jhipster-core project: https://github.com/jhipster/jhipster-core/pull/304. Sorry about that @Tonterias and thanks for reporting.

Also please notice that in the JDL you provided you need to change the display field name for 'Community' entity from communityname to 'communityName' (notice the upper case N) otherwise mapstruct will also complain when generating your DTO mappers. It is referenced both by Calbum and Blog entities

All 4 comments

You can see the issue in .jhipster/Activity.json:

        "otherEntityRelationshipName": "activity(activityName)",

Based on git bisect, the issue is in JHipster Core between versions v3.6.8 and v3.6.9. @pvliss might have an idea, maybe related to https://github.com/jhipster/jhipster-core/pull/302 or https://github.com/jhipster/jhipster-core/pull/300

efb9c0b603f97f67505563de11b4a678a47e3dc5 is the first bad commit
commit efb9c0b603f97f67505563de11b4a678a47e3dc5
Author: Julien Dubois <[email protected]>
Date:   Tue Jan 29 15:47:28 2019 +0100

    Update to the latest jhipster-core

:100644 100644 c0eb982a54df782fb842d58be781f8ceb98fe8e5 c3f70b4be4892017db96ff24435fd1a7820ae0f2 M  package-lock.json
:100644 100644 7156eb9b1c2bf72d258eb745fc7facc619cb911e fe33c9d0308b269b4f5ce5e0c31d0dd6848d6194 M  package.json

Thanks @ruddell for pinging me. I will check right away

So I found the bug and submitted a PR that fixes it at the jhipster-core project: https://github.com/jhipster/jhipster-core/pull/304. Sorry about that @Tonterias and thanks for reporting.

Also please notice that in the JDL you provided you need to change the display field name for 'Community' entity from communityname to 'communityName' (notice the upper case N) otherwise mapstruct will also complain when generating your DTO mappers. It is referenced both by Calbum and Blog entities

Thanks to all

Was this page helpful?
0 / 5 - 0 ratings