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

Java Service compilation issue when using ServicesClass with entitySuffix and Elasticsearch #26946

Closed khayassine closed 2 months ago

khayassine commented 2 months ago
Overview of the issue

Hello, We get a compilation error when setting a entitySuffix with serviceClass & searchEngineElasticsearch configurations

Motivation for or Use Case

Use Suffix for my Entities and ServiceClass and Elasticsearch on the same time !

Reproduce the error

Just configure the Entity as serviceClass, and enable Elasticsearch as search engine + set entitySuffix on application level

Related issues
Suggest a Fix

I think the fix should be this :

File : jhipster/generator-jhipster/blob/main/generators/spring-boot/templates/_global_partialsentity/save_template.ejs Line to Replace (36) : return <%- entityInstance %>; Correct line (36) : return <%- persistInstance %>;

JHipster Version(s)

Last version 8.6.0

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "testApp",
    "buildTool": "maven",
    "cacheProvider": "caffeine",
    "clientFramework": "react",
    "clientTestFrameworks": [],
    "clientTheme": "darkly",
    "clientThemeVariant": "primary",
    "creationTimestamp": 1723454747256,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 9060,
    "dtoSuffix": "DTO",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": [
      "Toto"
    ],
    "entitySuffix": "Entity",
    "feignClient": null,
    "jhipsterVersion": "8.6.0",
    "languages": [
      "fr",
      "en",
      "ar-ly"
    ],
    "lastLiquibaseTimestamp": 1723455044000,
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "fr",
    "packageFolder": "com/test/app",
    "packageName": "com.test.app",
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": "elasticsearch",
    "serverPort": "8080",
    "serverSideOptions": [
      "searchEngine:elasticsearch"
    ],
    "serviceDiscoveryType": false,
    "syncUserWithIdp": null,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": true
  }
}
Environment and Tools

java version "17.0.10" 2024-01-16 LTS Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240) Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)

git version 2.43.0.windows.1

node: v20.16.0 npm: 10.8.1

Docker version 26.1.4, build 5650f9b

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
@ChangelogDate("20240812093044")
entity Toto

paginate Toto with pagination
service Toto with serviceClass

Browsers and Operating System
DanielFran commented 2 months ago

Hi @khayassine Can you please update 1st post and add your jhipster configuration?

Please follow the instructions: To provide all information we need, you should run jhipster info in the project root folder, and copy/paste the result here. The .yo-rc.json file generated in the root folder is mandatory for bug reports. This will help us to replicate the scenario. You should remove any sensitive information like the rememberMe key or the jwtSecretKey key.

Thanks

khayassine commented 2 months ago

Hi @khayassine Can you please update 1st post and add your jhipster configuration?

Please follow the instructions: To provide all information we need, you should run jhipster info in the project root folder, and copy/paste the result here. The .yo-rc.json file generated in the root folder is mandatory for bug reports. This will help us to replicate the scenario. You should remove any sensitive information like the rememberMe key or the jwtSecretKey key.

Thanks

Hello @DanielFran, Done 👍

github-actions[bot] commented 2 months ago

JHipster has completed the sample check .yo-rc.json: valid Entities JDL: valid Application: successfully generated Frontend check: success Backend check: failure E2E check: skipped

This check uses jhipster info output from the issue description to generate the sample. Bug report that does not contain this information will be marked as invalid.

khayassine commented 2 months ago

Tested localy by changing the Line 36 on file save_template.ejs

this : return <%- entityInstance %>;

By this : return <%- persistInstance %>;

=> worked fine 👍

mshima commented 2 months ago

@khayassine can you provide the PR?