Generator-jhipster: Many to one relationship between entities gives error: TypeError: Cannot read property 'toLowerCase' of undefined

Created on 10 Apr 2020  路  7Comments  路  Source: jhipster/generator-jhipster

I have created First Entity with name "FirstEntity" with a field "name" of type String and ManyToOne Relationship with User entity. It was created successfully. When I tried creating second entity with name "SecondEntity" with a field "name" of type String and ManyToOne Relationship with "FirstEntity", its failing with this error:

`Everything is configured, generating the entity...

~~~
events.js:288
throw er; // Unhandled 'error' event
^

TypeError: Cannot read property 'toLowerCase' of undefined
at Function.plural (C:\Users\anshu\OneDrive\Desktop\tcs work from home\jhipster pocnode_modules\pluralize\pluralize.js:133:24)
at pluralize (C:\Users\anshu\OneDrive\Desktop\tcs work from home\jhipster pocnode_modules\pluralize\pluralize.js:174:46)
at C:\Users\anshu\OneDrive\Desktop\tcs work from home\jhipster pocnode_modulesgenerator-jhipstergenerators\entity\index.js:928:74
at Array.forEach ()
at EntityGenerator.loadInMemoryData (C:\Users\anshu\OneDrive\Desktop\tcs work from home\jhipster pocnode_modulesgenerator-jhipstergenerators\entity\index.js:877:39)
at Object. (C:\Users\anshu\OneDrive\Desktop\tcs work from home\jhipster pocnode_modules\yeoman-generator\lib\index.js:546:23)
at C:\Users\anshu\OneDrive\Desktop\tcs work from home\jhipster pocnode_modules\run-async\index.js:47:25
at new Promise ()
at C:\Users\anshu\OneDrive\Desktop\tcs work from home\jhipster pocnode_modules\run-async\index.js:24:19
at C:\Users\anshu\OneDrive\Desktop\tcs work from home\jhipster pocnode_modules\yeoman-generator\lib\index.js:547:9
Emitted 'error' event on EntityGenerator instance at:
at Immediate. (C:\Users\anshu\OneDrive\Desktop\tcs work from home\jhipster pocnode_modules\yeoman-generator\lib\index.js:559:18)
at processImmediate (internal/timers.js:456:21)
at process.topLevelDomainCallback (domain.js:137:15)`
~~~

I added a console.log on line 928 of node_modules/generator-jhipster/generators/entity/index.js
and following was printed:

~
{
relationshipName: 'firstEntity',
otherEntityName: 'firstEntity',
relationshipType: 'many-to-one',
relationshipValidateRules: undefined,
otherEntityField: 'id',
ownerSide: undefined,
useJPADerivedIdentifier: undefined,
otherEntityRelationshipName: undefined
}
~

I can guess otherEntityRelationshipName is undefined because of which it is throwing error.

JHipster Version(s)

Jhipster version: 6.7.1

JHipster configuration


.yo-rc.json file

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp"
    },
    "jhipsterVersion": "6.7.1",
    "applicationType": "monolith",
    "baseName": "jhipster",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8080",
    "authenticationType": "session",
    "cacheProvider": "caffeine",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,

    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "cerulean",
    "clientThemeVariant": "primary",
    "creationTimestamp": 1586358157593,
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": false,
    "blueprints": []
  }
}

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

Using command line

Browsers and Operating System

Windows 10 OS

[how to check? ] Checking this box is mandatory (this is just to show you read everything)

relationships

Most helpful comment

You should try npm install jhipster/generator-jhipster#master to fix this bug.

After generating the project you probably can downgrade if you want;

npm install [email protected]
jhipster 鈥攚ith-entities

All 7 comments

I think it鈥檚 fixed on master.

It was not working on 6.8 version either... which is the right version to use? I first added this question on stackoverflow, with all the screenshots of entity creation, but got no proper response

https://stackoverflow.com/questions/61102634/jhipster-entity-creation-is-giving-error-cannot-read-property-tolowercase-of

You should try npm install jhipster/generator-jhipster#master to fix this bug.

After generating the project you probably can downgrade if you want;

npm install [email protected]
jhipster 鈥攚ith-entities

Closing.
@anshulcoolans880 if you manage to reproduce using master, please reopen.

On a side note, there are undefined values in what was logged.
@anshulcoolans880 please follow the issue template, otherwise we won't be able to reproduce the issue and fix it.

Yup, good catch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SudharakaP picture SudharakaP  路  3Comments

marcelinobadin picture marcelinobadin  路  3Comments

pascalgrimaud picture pascalgrimaud  路  3Comments

shivroy121 picture shivroy121  路  3Comments

tomj0101 picture tomj0101  路  3Comments