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

Unable to generate relationship in entity sub generator #14525

Closed kaidohallik closed 1 year ago

kaidohallik commented 3 years ago
Overview of the issue

If trying to add new entity and add relationship to another entity then error occurs and entity is not generated.

C:\projects\teest\jhipster-rel>jhipster entity Entity2
INFO! Using JHipster version installed globally

The entity Entity2 is being created.

Generating field #1

? Do you want to add a field to your entity? Yes
? What is the name of your field? field2
? What is the type of your field? String
? Do you want to add validation rules to your field? No

================= Entity2 =================
Fields
field2 (String)

Generating field #2

? Do you want to add a field to your entity? No

================= Entity2 =================
Fields
field2 (String)

Generating relationships to other entities

? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? Entity1
? What is the name of the relationship? entity1
? What is the type of the relationship? one-to-many
? What is the name of this relationship in the other entity? entity2

================= Entity2 =================
Fields
field2 (String)

Relationships
entity1 (Entity1) one-to-many

Generating relationships to other entities

? Do you want to add a relationship to another entity? No

================= Entity2 =================
Fields
field2 (String)

Relationships
entity1 (Entity1) one-to-many

? Do you want to use separate service class for your business logic? No, the REST controller should use the repository directly
? Is this entity read-only? No
? Do you want pagination and sorting on your entity? Yes, with pagination links and sorting headers

Everything is configured, generating the entity...

Found the .jhipster\Entity1.json configuration file, entity can be automatically generated!

     info Creating changelog for entities Entity1,Entity2
ERROR! Error at entity Entity2: could not find the other side of the relationship {
    "relationshipName": "entity1",
    "otherEntityName": "entity1",
    "relationshipType": "one-to-many",
    "otherEntityRelationshipName": "entity2",
    "otherEntity": "[Entity1 Entity]",
    "otherEntityField": "id",
    "ownerSide": false,
    "collection": true,
    "otherSideReferenceExists": false,
    "otherEntityIsEmbedded": false
}
Error: Error at entity Entity2: could not find the other side of the relationship {
    "relationshipName": "entity1",
    "otherEntityName": "entity1",
    "relationshipType": "one-to-many",
    "otherEntityRelationshipName": "entity2",
    "otherEntity": "[Entity1 Entity]",
    "otherEntityField": "id",
    "ownerSide": false,
    "collection": true,
    "otherSideReferenceExists": false,
    "otherEntityIsEmbedded": false
}
    at prepareRelationshipForTemplates (C:\projects\kaido-github\generator-jhipster\utils\relationship.js:107:13)
    at C:\projects\kaido-github\generator-jhipster\generators\entity\index.js:581:11
    at Array.forEach (<anonymous>)
    at EntityGenerator.prepareRelationshipsForTemplates (C:\projects\kaido-github\generator-jhipster\generators\entity\index.js:580:36)
    at Object.<anonymous> (C:\projects\kaido-github\generator-jhipster\node_modules\yeoman-generator\lib\index.js:1009:25)
    at C:\projects\kaido-github\generator-jhipster\node_modules\run-async\index.js:49:25
    at new Promise (<anonymous>)
    at C:\projects\kaido-github\generator-jhipster\node_modules\run-async\index.js:26:19
    at runLoop.add.once.once (C:\projects\kaido-github\generator-jhipster\node_modules\yeoman-generator\lib\index.js:1010:11)
    at Immediate.<anonymous> (C:\projects\kaido-github\generator-jhipster\node_modules\grouped-queue\lib\subqueue.js:48:34)
    at processImmediate (internal/timers.js:461:21)
Motivation for or Use Case

Entity sub generator should work without errors.

Reproduce the error
Related issues
Suggest a Fix
JHipster Version(s)
jhipster@0.0.1-SNAPSHOT C:\projects\teest\jhipster-rel
`-- generator-jhipster@7.0.0 -> C:\projects\kaido-github\generator-jhipster
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "blueprints": [],
    "otherModules": [],
    "applicationType": "monolith",
    "baseName": "jhipster",
    "jhipsterVersion": "7.0.0",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": [],
    "pages": [],
    "creationTimestamp": 1617114233083,
    "serviceDiscoveryType": false,
    "reactive": false,
    "authenticationType": "jwt",
    "packageName": "com.mycompany.myapp",
    "serverPort": "8080",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "buildTool": "gradle",
    "serverSideOptions": [],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "angularX",
    "withAdminUi": true,
    "clientTheme": "none",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "packageFolder": "com/mycompany/myapp",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "clientPackageManager": "npm",
    "clientThemeVariant": "",
    "languages": ["en", "et"],
    "lastLiquibaseTimestamp": 1617114524000,
    "entities": ["Entity1"]
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Entity1 {
  field1 String
}
paginate Entity1 with pagination

Environment and Tools

openjdk version "11.0.8" 2020-07-14 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)

git version 2.31.1.windows.1

node: v14.16.0

npm: 7.7.6

Docker version 20.10.5, build 55c4c88

docker-compose version 1.28.5, build c4eb3a1f

Browsers and Operating System

Windows 10

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted. We are accepting PRs :smiley:. Comment or this will be closed in 7 days

DanielFran commented 2 years ago

@kaidohallik Can you please confirm if issue persist or this can be closed?

sanjayrawat1 commented 2 years ago

@DanielFran this issue still not resolved. I am using jhipster v7.8.1