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

Created Entity not displayed under entity menu in Angular 2 #20827

Closed berndwaibel closed 9 months ago

berndwaibel commented 1 year ago
Overview of the issue

When running the jhipster jdl generator twice, all Entities are removed on second run from Navigation bar. So the created Entites List in the generated Angular Frontend is empty.

Motivation for or Use Case

When I add new Entities, I will run the jhipster generator again to add the new entries. But he removes als entries from generated navbar.

Reproduce the error

Generate any jhipster jdl file, for example using the JDL GUI examples at (https://start.jhipster.tech/jdl-studio/). Call the file "jhipster-jdl.jdl" (name does not matter, but is following used. The file should be related to microservices, and should contain applications and entities.

I am using git bash on Windows for following commands.

  1. Copy jhipster-jdl.jdl to a new folder
  2. Run git init
  3. Run git add jhipster-jdl.jdl
  4. Run git commit -m "test"
  5. Run git status (nothing should be uncommitted)
  6. Run "jhipster jdl jhipster-jdl.jdl"
  7. Run git status (nothing should be uncommitted)
  8. Run "jhipster jdl jhipster-jdl.jdl" again. Answer "a" to regenerate all files.
  9. Run "git status", and you will see changes in the generated Angular and Java and XML files.

The following files are changed: modified: testGateway/src/main/resources/config/liquibase/master.xml modified: testGateway/src/main/webapp/app/entities/entity-navbar-items.ts modified: testGateway/src/main/webapp/app/entities/entity-routing.module.ts modified: testGateway/src/main/webapp/app/layouts/navbar/navbar.component.html modified: testGateway/src/main/webapp/i18n/en/global.json modified: testService/src/main/java/de/bwaibel/test/config/CacheConfiguration.java modified: testService/src/main/resources/config/liquibase/master.xml

If you use " jhipster jdl --ignore-application jhipster-jdl.jdl" instead, no error happens, as nothing will be regenerated.

If you use "jhipster jdl jhipster-jdl.jdl", all entities are removed from applications.

Related issues

Related bug, closed without change, is here: https://github.com/jhipster/generator-jhipster/issues/5192

Suggest a Fix

When running the jdl generator twice, and applicaton and entities exists already, do not regenerate the components listed above. Or regenerate the entites too.

JHipster Version(s)

JHipster v7.9.2 JHipster Generator Version

JHipster configuration

INFO! Using bundled JHipster Welcome to JHipster v7.9.2

Welcome to the JHipster Information Sub-Generator

C:\Users\Bernd\git\xxxxxxxx\test
└── (empty)

cat: no such file or directory: .yo-rc.json

JHipster configuration, a .yo-rc.json file generated in the root folder

This is from gateway:

.yo-rc.json file
{
  "generator-jhipster": {
    "applicationIndex": 0,
    "applicationType": "gateway",
    "authenticationType": "oauth2",
    "baseName": "testGateway",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "angularX",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1673793422331,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 4200,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": ["Address", "Person", "UserRegistration"],
    "entitySuffix": "",
    "gradleEnterpriseHost": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.9.2",
    "jwtSecretKey": "xxxxxx=",
    "languages": ["en"],
    "lastLiquibaseTimestamp": 1673793602000,
    "messageBroker": false,
    "monorepository": true,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageFolder": "de/bwaibel/test",
    "packageName": "de.bwaibel.test",
    "pages": [],
    "prodDatabaseType": "postgresql",
    "reactive": true,
    "searchEngine": false,
    "serverPort": "8080",
    "serviceDiscoveryType": "eureka",
    "skipCheckLengthOfIdentifier": false,
    "skipCommitHook": true,
    "skipFakeData": false,
    "skipUserManagement": true,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": true
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
Environment and Tools

openjdk version "17.0.2" 2022-01-18 OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8) OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)

git version 2.35.1.windows.2

node: v18.12.1

npm: 8.19.2

Docker version 20.10.21-rd, build ac29474

Docker Compose version v2.14.0

No change to package.json was detected. No package manager install will be executed. Congratulations, JHipster execution is complete!

INFO: The json Files are created in the subdirectories of the gateway and the service, so not listed here.

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

This is from Gateway:

JDL entity definitions Person.json
{
  "applications": ["testGateway", "testService"],
  "changelogDate": "20230115143902",
  "databaseType": "sql",
  "dto": "mapstruct",
  "embedded": false,
  "entityTableName": "person",
  "fields": [
    {
      "fieldName": "firstName",
      "fieldType": "String"
    },
    {
      "fieldName": "lastName",
      "fieldType": "String"
    },
    {
      "fieldName": "email",
      "fieldType": "String"
    },
    {
      "fieldName": "phoneNumber",
      "fieldType": "String"
    },
    {
      "fieldName": "language",
      "fieldType": "String"
    }
  ],
  "fluentMethods": true,
  "jpaMetamodelFiltering": false,
  "name": "Person",
  "pagination": "pagination",
  "readOnly": false,
  "relationships": [
    {
      "otherEntityName": "userRegistration",
      "ownerSide": true,
      "relationshipName": "registration",
      "relationshipType": "one-to-one"
    },
    {
      "otherEntityName": "address",
      "ownerSide": true,
      "relationshipName": "homeAddress",
      "relationshipType": "one-to-one"
    }
  ],
  "service": "serviceImpl"
}
JDL entity definitions Address.json
{
  "applications": ["testGateway", "testService"],
  "changelogDate": "20230115143802",
  "databaseType": "sql",
  "dto": "mapstruct",
  "embedded": false,
  "entityTableName": "address",
  "fields": [
    {
      "fieldName": "street",
      "fieldType": "String"
    },
    {
      "fieldName": "streetNumber",
      "fieldType": "Integer"
    },
    {
      "fieldName": "postalCode",
      "fieldType": "String"
    },
    {
      "fieldName": "city",
      "fieldType": "String"
    },
    {
      "fieldName": "stateProvince",
      "fieldType": "String"
    },
    {
      "fieldName": "country",
      "fieldType": "String"
    }
  ],
  "fluentMethods": true,
  "jpaMetamodelFiltering": false,
  "name": "Address",
  "pagination": "no",
  "readOnly": false,
  "relationships": [],
  "service": "serviceImpl"
}
JDL entity definitions UserRegistration.json
{
  "applications": ["testGateway", "testService"],
  "changelogDate": "20230115144002",
  "databaseType": "sql",
  "dto": "mapstruct",
  "embedded": false,
  "entityTableName": "user_registration",
  "fields": [
    {
      "fieldName": "userid",
      "fieldType": "String"
    }
  ],
  "fluentMethods": true,
  "jpaMetamodelFiltering": false,
  "name": "UserRegistration",
  "pagination": "no",
  "readOnly": false,
  "relationships": [],
  "service": "serviceImpl"
}

JDL File

jhipster-jdl.jdl file
application {
    config {
        baseName testGateway,
        applicationType gateway,
        packageName de.bwaibel.test,
        authenticationType oauth2,
        prodDatabaseType postgresql,
        clientFramework angular
    }
    entities *
    dto * with mapstruct
    paginate Person with pagination
}

application {
    config {
        baseName testService,
        applicationType microservice,
        packageName de.bwaibel.test,
        authenticationType oauth2,
        prodDatabaseType postgresql,
    }
    entities Address, Person, UserRegistration
    dto * with mapstruct
    service * with serviceImpl
    paginate Person with pagination
}

entity Address {
    street String,
    streetNumber Integer,
    postalCode String,
    city String,
    stateProvince String,
    country String
}

entity Person {
    firstName String,
    lastName String,
    email String,
    phoneNumber String,
    language String,
}

entity UserRegistration {
    userid String
}

relationship OneToOne {
    Person{registration} to UserRegistration
}

relationship OneToOne {
    Person{homeAddress} to Address
}
Browsers and Operating System

Windows 10, all browser behave the same (as the source code is missing the entities).

mshima commented 1 year ago

To regenerate with entities you need --with-entities option.

Rizen59 commented 1 year ago

I confirm having the same issue. If you generate entities from jdl twice without any modification the second time it will :

But if you generate entities from jdl a second time with a new entity in the jdl :

I did my tests in an existing project so if you do not succeed to reproduce it I can try in a brand new project to give additional information.

Command used : jhipster jdl example.jdl During generation, all files are overriden when it was asked

Environment:

java version "17.0.2" 2022-01-18 LTS Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86) Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)

JHipster 7.9.3 npm 9.6.6 node 16.20.0

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for too long without any activity. Due to the moving nature of jhipster generated application, bugs can become invalid. If this issue still applies please comment otherwise it will be closed in 7 days