Generator-jhipster: Generator adds ignore rule for remove method in Mapper classes

Created on 13 Sep 2019  ·  7Comments  ·  Source: jhipster/generator-jhipster

Overview of the issue

The mappers are generated with ignore rules for lists but also for their remove metthods like this:

@Mapping(target = "clients", ignore = true)
@Mapping(target = "removeClient", ignore = true)
@Mapping(target = "projects", ignore = true)
@Mapping(target = "removeProject", ignore = true)
@Mapping(target = "clientInvoices", ignore = true)
@Mapping(target = "removeClientInvoice", ignore = true)
Motivation for or Use Case

I do not think it is a real problem the mapper class was not mapping these methods nor was it complaining about it. And the add methods are also no problem (like addClient) so i think this can be removed again

Reproduce the error

use the generator to add a new entity to the model. The mapper generated will have the ignore rules.

Suggest a Fix

remove it again.

JHipster Version(s)

6.2.0

JHipster configuration

INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:info
INFO! Options: from-cli: true
Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
[email protected] /home/tibi/git/standBystand
└── [email protected] 

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "nl.tibi.sbys",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "6.2.0",
    "baseName": "standBystand",
    "packageName": "nl.tibi.sbys",
    "packageFolder": "nl/tibi/sbys",
    "serverPort": "8080",
    "authenticationType": "session",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSocialSignIn": true,
    "enableSwaggerCodegen": false,
    "rememberMeKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "npm",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": ["en", "nl", "de", "fr"],
    "otherModules": [],
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "clientTheme": "none",
    "blueprints": []
  }
}

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


JDL entity definitions

...

Environment and Tools

openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~19.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

git version 2.20.1

node: v12.9.1

npm: 6.10.2

yarn: 1.9.4

Docker version 18.09.7, build 2d0083d

docker-compose version 1.21.0, build unknown

INFO! Congratulations, JHipster execution is complete!

will-do-later mapstruct

Most helpful comment

I am one of the MapStruct maintainers and it feels like we can and should do better about this.

I don't know much about the structure of the entities that jHipster generates. For the removeXXX perhaps we can do something similar like with the adder methods.

I am curious about the other methods though clients for example. Is it on purpose that you don't want to map the lists, or is it something because of MapStruct?

All 7 comments

This was added in #9784 to fix #9726. If you remove the ignore=true, is there some warnings in the console ?

There is also maybe a better way to deal with that

thanks for the feedback. maybe i missed the warning. i will investigate.

I think we don't have a better way currently, we need to wait for a solution from mapstruct

Maybe look into make our own AccessorNamingStrategy.

Not sure we can do better.
As it seems not to be on our side but related to mapstruct, I'm closing this.

I am one of the MapStruct maintainers and it feels like we can and should do better about this.

I don't know much about the structure of the entities that jHipster generates. For the removeXXX perhaps we can do something similar like with the adder methods.

I am curious about the other methods though clients for example. Is it on purpose that you don't want to map the lists, or is it something because of MapStruct?

@filiphr it would be great to the the MapStruct improved. Also good for you project to have it working properly.

I think we do not want to map the list because we do not want to get the whole tree to go to the frontend.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edvjacek picture edvjacek  ·  3Comments

shivroy121 picture shivroy121  ·  3Comments

frantzynicolas picture frantzynicolas  ·  3Comments

DanielFran picture DanielFran  ·  3Comments

marcelinobadin picture marcelinobadin  ·  3Comments