generator-jhipster: Interactive entity generator fails on TypeError: Cannot read property 'toLowerCase' of undefined

Overview of the issue

While using the entity interactive generator, and creating a many to one relationship to another entity The process fails on ERROR! TypeError: Cannot read property 'toLowerCase' of undefined Just a line after Everything is configured, generating the entity.... Generating this entity with same relationship from <EntityName>.json works just fine

Motivation for or Use Case

Interactively generation entity with many-to-one relationship to another entity

Reproduce the error

Step 1

Welcome to JHipster v6.8.0

 _______________________________________________________________________________________________________________

  Documentation for creating an application is at https://www.jhipster.tech/creating-an-app/
  If you find JHipster useful, consider sponsoring the project at https://opencollective.com/generator-jhipster
 _______________________________________________________________________________________________________________

? Which *type* of application would you like to create? Monolithic application (recommended for simple projects)
? [Alpha] Do you want to make it reactive with Spring WebFlux? No
? What is the base name of your application? jhipster
? What is your default Java package name? com.norr.tr
? Do you want to use the JHipster Registry to configure, monitor and scale your application? No
? Which *type* of authentication would you like to use? JWT authentication (stateless, with a token)
? Which *type* of database would you like to use? SQL (H2, MySQL, MariaDB, PostgreSQL, Oracle, MSSQL)
? Which *production* database would you like to use? MySQL
? Which *development* database would you like to use? MySQL
? Do you want to use the Spring cache abstraction? Yes, with the Ehcache implementation (local cache, for a single node)
? Do you want to use Hibernate 2nd level cache? Yes
? Would you like to use Maven or Gradle for building the backend? Maven
? Which other technologies would you like to use? (Press <space> to select, <a> to toggle all, <i> to invert selection)
? Which *Framework* would you like to use for the client? Angular
? Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster
? Would you like to enable internationalization support? No
? Besides JUnit and Jest, which testing frameworks would you like to use? (Press <space> to select, <a> to toggle all, <i> to invert selection)
? Would you like to install other generators from the JHipster Marketplace? No

Step 2

➜  final-rrr git:(master) jhipster entity author
INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:entity author
INFO! Options: from-cli: true

The entity author is being created.


Generating field #1

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

================= Author =================
Fields
name (String) 


Generating field #2

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

================= Author =================
Fields
name (String) 


Generating relationships to other entities

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

================= Author =================
Fields
name (String) 



? Do you want to use separate service class for your business logic? Yes, generate a separate service class
? Do you want to use a Data Transfer Object (DTO)? No, use the entity directly
? Do you want to add filtering? Not needed
? Is this entity read-only? No
? Do you want pagination on your entity? Yes, with pagination links

Everything is configured, generating the entity...

   create .jhipster/Author.json
   create src/main/resources/config/liquibase/changelog/20200327222530_added_entity_Author.xml
   create src/main/resources/config/liquibase/fake-data/author.csv
   create src/main/java/com/norr/tr/domain/Author.java
   create src/main/java/com/norr/tr/repository/AuthorRepository.java
   create src/main/java/com/norr/tr/web/rest/AuthorResource.java
   create src/main/java/com/norr/tr/service/AuthorService.java
   create src/test/java/com/norr/tr/web/rest/AuthorResourceIT.java
   create src/test/java/com/norr/tr/domain/AuthorTest.java
 conflict src/main/resources/config/liquibase/master.xml
? Overwrite src/main/resources/config/liquibase/master.xml? overwrite this and all others

Step 3

➜  final-rrr git:(master) ✗ jhipster entity book 
INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:entity book
INFO! Options: from-cli: true

The entity book is being created.


Generating field #1

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

================= Book =================
Fields
title (String) 


Generating field #2

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

================= Book =================
Fields
title (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? author
? What is the name of the relationship? author
? What is the type of the relationship? many-to-one
? When you display this relationship on client-side, which field from 'author' do you want to use? This field will be displayed as a String, so it cannot be a Blob name
? Do you want to add any validation rules to this relationship? No

================= Book =================
Fields
title (String) 

Relationships
author (Author) many-to-one 


Generating relationships to other entities

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

================= Book =================
Fields
title (String) 

Relationships
author (Author) many-to-one 



? Do you want to use separate service class for your business logic? Yes, generate a separate service class
? Do you want to use a Data Transfer Object (DTO)? No, use the entity directly
? Do you want to add filtering? Not needed
? Is this entity read-only? No
? Do you want pagination on your entity? Yes, with pagination links

Everything is configured, generating the entity...

ERROR! TypeError: Cannot read property 'toLowerCase' of undefined

Here after step 3 I’m getting the error ERROR! TypeError: Cannot read property ‘toLowerCase’ of undefined

Related issues
Suggest a Fix
JHipster Version(s)

Jhipster 6.8.0

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

Author.json:

{
    "fluentMethods": true,
    "clientRootFolder": "",
    "relationships": [],
    "fields": [
        {
            "fieldName": "name",
            "fieldType": "String"
        }
    ],
    "changelogDate": "20200327222530",
    "dto": "no",
    "searchEngine": false,
    "service": "serviceClass",
    "entityTableName": "author",
    "databaseType": "sql",
    "readOnly": false,
    "jpaMetamodelFiltering": false,
    "pagination": "pagination"
}
Browsers and Operating System

Operating system MacOS Catalina version 10.15.2

  • Checking this box is mandatory (this is just to show you read everything)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 29 (29 by maintainers)

Most upvoted comments

Wow I’m very exited thanks a lot 😃

I’m going to sleep, I think @mshima would be interested to follow up on this issue (maybe @SudharakaP you can help too?). Anyway, @ramiloif thanks for the report and nice work 😃

@ramiloif should claim it for know. My doubt is if we should open a new issue for the other issue. I will try to confirm it.

There are uni and bidirectional relationships, the JDL supports both as does JHipster. There are some cases where only bidirectional are supported though, and ways to generate relationships have full support.

I’m adding a bounty on this as @MathieuAA you confirmed the issue

Ok I found the line causes the bug https://github.com/jhipster/generator-jhipster/blob/add8f07d59c2967b28a4fbd07a6ab9b938774ee2/generators/entity/index.js#L945

This Issue is on “A unidirectional many-to-one relationship” So there is no otherEntityRelationship so relationship.otherEntityRelationshipName is undefined