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

How to fix "Java type Integer does not have a random generator implemented " #21435

Closed sasconsul closed 1 year ago

sasconsul commented 1 year ago
Overview of the issue

For each entity that I have declared an 'Integer' I am getting the ERROR message:

Error running generator app: Error: /Users/sasconsul/devenv/github/sasconsul/CarYParkingUI/node_modules/generator-jhipster/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs:852 
    850| <%_ if (!primaryKey.derived) { _%> 
    851| <%_ for (field of primaryKey.fields.filter(f => !f.autoGenerateByRepository)) { _%> 
 >> 852|         <%= persistInstance %>.set<%= field.fieldNameCapitalized %>(<%- getJavaValueGeneratorForType(field.fieldType) %>); 
    853| <%_ } _%> 
    854| <%_ } _%> 
    855|         <%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>; 

Java type Integer does not have a random generator implemented 
Motivation for or Use Case

It is a bug since none of the entities have code generated if they have an 'Integer' field declared.

Reproduce the error
Related issues
Suggest a Fix
JHipster Version(s)
jhipster --version
INFO! Switching to JHipster installed locally in current project's node repository (node_modules)
7.1.0
JHipster configuration

| jhipster info INFO! Switching to JHipster installed locally in current project's node repository (node_modules) Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
car-y-parking-ui@0.0.1-SNAPSHOT /Users/sasconsul/devenv/github/sasconsul/CarYParkingUI
└── generator-jhipster@7.1.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "CarYParkingUI",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "react",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1678852381622,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 9060,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entitySuffix": "",
    "gitCompany": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.9.3",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en", "es"],
    "messageBroker": false,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageFolder": "net/sasconsul/caryparking/ui",
    "packageName": "net.sasconsul.caryparking.ui",
    "pages": [],
    "prodDatabaseType": "mysql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": 8080,
    "serviceDiscoveryType": false,
    "skipCheckLengthOfIdentifier": false,
    "skipClient": false,
    "skipFakeData": false,
    "skipUserManagement": false,
    "testFrameworks": ["cucumber"],
    "useSass": true,
    "websocket": false,
    "withAdminUi": true
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "14.0.2" 2020-07-14 OpenJDK Runtime Environment (build 14.0.2+12-46) OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

git version 2.37.1 (Apple Git-137.1)

node: v19.8.0

npm: 9.5.1

Docker version 20.10.20, build 9fdeb9c

Docker Compose version v2.12.0

No change to package.json was detected. No package manager install will be executed. Congratulations, JHipster execution is complete! Sponsored with ❤️ by @oktadev.

.yo-rc.json

{ "generator-jhipster": { "applicationType": "monolith", "authenticationType": "jwt", "baseName": "CarYParkingUI", "blueprints": [], "buildTool": "maven", "cacheProvider": "no", "clientFramework": "react", "clientPackageManager": "npm", "clientTheme": "none", "clientThemeVariant": "", "creationTimestamp": 1678852381622, "databaseType": "sql", "devDatabaseType": "h2Disk", "devServerPort": 9060, "dtoSuffix": "DTO", "enableGradleEnterprise": false, "enableHibernateCache": false, "enableSwaggerCodegen": false, "enableTranslation": true, "entitySuffix": "", "gitCompany": "", "jhiPrefix": "jhi", "jhipsterVersion": "7.9.3", "languages": ["en", "es"], "messageBroker": false, "nativeLanguage": "en", "otherModules": [], "packageFolder": "net/sasconsul/caryparking/ui", "packageName": "net.sasconsul.caryparking.ui", "pages": [], "prodDatabaseType": "mysql", "reactive": false, "searchEngine": false, "serverPort": 8080, "serviceDiscoveryType": false, "skipCheckLengthOfIdentifier": false, "skipClient": false, "skipFakeData": false, "skipUserManagement": false, "testFrameworks": ["cucumber"], "useSass": true, "websocket": false, "withAdminUi": true } }

JDL
JDL definitions

application {
  config {
    baseName myApp,
    applicationType monolith,
    packageName com.myapp,
    authenticationType jwt,
    prodDatabaseType mysql,
    clientFramework react
  }
  entities *
}

entity Car {
    name String,
    numberOfSeats Integer,
    currentSpeed Double,
    productionNumber Integer,
    horsepower Double,
    mpg Double,
    convertible Boolean,
    roofUp Boolean
   /* The car should have a method of
      accelerating with an input of -1.0 to 1.0 that takes the engines
      horse-power into account (units, wind resistance etc. are irrelevant) 
      Double accelerate(peddle [-1.0, 1.0]) 
   */

    /*  
       formats its characteristics name, car-type,
       production number and horse power as a string.

       String characteristics()
    */

    /*
        boolean IsRoofUp()
    */

}

entity Space {
    id Integer,
    carId Integer
}

entity ParkingLot {
    maxSpace Integer
}

relationship OneToMany {
  ParkingLot{Spaces} to Space
}

relationship OneToOne {
  Car{id} to Space{carId}
}

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

No entities get generated

Browsers and Operating System

Mac OS 13.2.1 (22D68)

sasconsul commented 1 year ago

This is 'fixed' by changing Integer declarations to Long.

github-actions[bot] commented 1 year 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