generator-jhipster icon indicating copy to clipboard operation
generator-jhipster copied to clipboard

Entity generator do not ask for fieldType when no persistence

Open henri-tremblay opened this issue 4 years ago • 14 comments

Overview of the issue

I have generate a project which use "No database". I'm generating an entity for it. It used to be forbidden but in version 7.0.0-beta.0 it seems to now be allowed, which is really cool.

The following things do not work:

  1. The generator doesn't ask for any field type. The field type is undefined and the generator fails with an error
  2. Repository classes are generated
  3. Service and IT tests are referring to the repository (which causes compilation errors and a crash in prettier)
  4. The entity is annotated with @Id
Motivation for or Use Case

I want a read-only script that will present information coming from calls on other APIs. So I don't need the persistence but having the UI and controllers is really useful.

Reproduce the error
  1. Generate a project with no persistence
  2. Create an entity
Related issues

N/A

Suggest a Fix
  • Field type should be asked. The list is probably coming from the persistence type so I suggest some hardcoded list (String, LocalDate, Integer, ...)
  • The generated code should have no JPA annotation on the entity
  • The repository classe should not be generated
  • The service should be generated without using a repository and with not content (todos, empty Optionals and empty lists)
  • The IT tests should use no repository. It could check that empty stuff is indeed returned
JHipster Version(s)

7.0.0-beta.0

JHipster configuration
{
  "generator-jhipster": {
    "blueprints": [],
    "otherModules": [],
    "applicationType": "monolith",
    "baseName": "allo",
    "jhipsterVersion": "7.0.0-beta.0",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": true,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": [],
    "pages": [],
    "creationTimestamp": 1611021758835,
    "promptValues": {
      "packageName": "com.mycompany.myapp",
      "nativeLanguage": "en"
    },
    "serviceDiscoveryType": false,
    "reactive": false,
    "authenticationType": "jwt",
    "packageName": "com.mycompany.myapp",
    "serverPort": "8080",
    "cacheProvider": "ehcache",
    "enableHibernateCache": false,
    "databaseType": "no",
    "buildTool": "maven",
    "serverSideOptions": [],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "angularX",
    "withAdminUi": true,
    "clientTheme": "none",
    "enableTranslation": false,
    "nativeLanguage": "en",
    "packageFolder": "com/mycompany/myapp",
    "jwtSecretKey": "OGQ3OGFiYmExMDk2MWNjN2Q2ZDJlMDllMGEyZTJmZGUyNTc4MzA3ZDljZDcxZmQyYWI4NGYzMGYwOTBjOGI3NzY4YjkxNWU1ZTdiMTRkNmM2MTZjZTA5MzA1ZmJhMmJjMjA2MWU3NThlZmEwOTY2NzQwYzdlZTY1NzM4ZDYxZWM=",
    "devDatabaseType": "no",
    "prodDatabaseType": "no",
    "clientPackageManager": "npm",
    "clientThemeVariant": "",
    "languages": ["en", "fr"]
  }
}
Entity configuration(s) entityName.json files generated in the .jhipster directory

N/A

Browsers and Operating System

macOS Catalina

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

henri-tremblay avatar Jan 19 '21 02:01 henri-tremblay

Side comment: "languages": ["en", "fr"] is weird. I have generated without international support and English as the language.

henri-tremblay avatar Jan 19 '21 02:01 henri-tremblay

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

github-actions[bot] avatar Feb 22 '21 00:02 github-actions[bot]

Issue it still valid with beta-1 1- Create a project without a database 2- Add an entity (jhipster entity Item) with whatever field (e.g name)

  • No type asked
  • Error right after because of it
ERROR! fieldType is missing in .jhipster/Item.json for field {
    "fieldName": "name"
}
Error: fieldType is missing in .jhipster/Item.json for field {
    "fieldName": "name"
}
    at EntityGenerator._validateField (/.../aaa/node_modules/generator-jhipster/generators/entity/index.js:856:19)
    at /.../aaa/node_modules/generator-jhipster/generators/entity/index.js:382:26
    at Array.forEach (<anonymous>)
    at EntityGenerator.configureFields (/.../aaa/node_modules/generator-jhipster/generators/entity/index.js:376:24)
    at Object.<anonymous> (/.../aaa/node_modules/yeoman-generator/lib/index.js:991:25)
    at /.../aaa/node_modules/run-async/index.js:49:25
    at new Promise (<anonymous>)
    at /.../aaa/node_modules/run-async/index.js:26:19
    at runLoop.add.once.once (/.../aaa/node_modules/yeoman-generator/lib/index.js:992:11)
    at processImmediate (internal/timers.js:461:21)

henri-tremblay avatar Feb 22 '21 03:02 henri-tremblay

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

github-actions[bot] avatar Mar 26 '21 00:03 github-actions[bot]

Still valid!

henri-tremblay avatar Mar 26 '21 02:03 henri-tremblay

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

github-actions[bot] avatar Apr 26 '21 00:04 github-actions[bot]

Still valid (from as far as I know)!

henri-tremblay avatar Apr 26 '21 11:04 henri-tremblay

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

github-actions[bot] avatar May 27 '21 00:05 github-actions[bot]

Still valid

henri-tremblay avatar May 27 '21 00:05 henri-tremblay

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

github-actions[bot] avatar Jun 28 '21 00:06 github-actions[bot]

Still valid I think

henri-tremblay avatar Jun 28 '21 01:06 henri-tremblay

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

github-actions[bot] avatar Jul 31 '21 00:07 github-actions[bot]

Generating field #1

? Do you want to add a field to your entity? Yes ? What is the name of your field? userid ? Do you want to add validation rules to your field? Yes ? Which validation rules do you want to add?

================= Bp ================= Fields userid (undefined)

Generating field #2

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

================= Bp ================= Fields userid (undefined) added_timestamp (undefined)

Generating field #3

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

================= Bp ================= Fields userid (undefined) added_timestamp (undefined)

Generating relationships to other entities

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

================= Bp ================= Fields userid (undefined) added_timestamp (undefined)

? Do you want to use separate service class for your business logic? Yes, generate a separate service interface and implementation ? Do you want to use a Data Transfer Object (DTO)? Yes, generate a DTO with MapStruct ? Is this entity read-only? Yes ? Do you want pagination and sorting on your entity? No

Everything is configured, generating the entity...

ERROR! fieldType is missing in .jhipster/Bp.json for field { "fieldName": "userid", "fieldValidateRules": [] } Error: fieldType is missing in .jhipster/Bp.json for field { "fieldName": "userid", "fieldValidateRules": [] } at EntityGenerator._validateField (/home/mylogic/projects/bpbook/node_modules/generator-jhipster/generators/entity/index.js:1089:13) at /home/mylogic/projects/bpbook/node_modules/generator-jhipster/generators/entity/index.js:454:16 at Array.forEach () at EntityGenerator.configureFields (/home/mylogic/projects/bpbook/node_modules/generator-jhipster/generators/entity/index.js:445:16) at Object. (/home/mylogic/projects/bpbook/node_modules/yeoman-generator/lib/index.js:1097:23) at /home/mylogic/projects/bpbook/node_modules/run-async/index.js:49:25 at new Promise () at /home/mylogic/projects/bpbook/node_modules/run-async/index.js:26:19 at /home/mylogic/projects/bpbook/node_modules/yeoman-generator/lib/index.js:1098:9 at new Promise ()

This issue is still there!!

skillet-loki avatar Jul 23 '22 15:07 skillet-loki

Just ran into this as well:)

alina-yur avatar Aug 21 '22 11:08 alina-yur

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

github-actions[bot] avatar Oct 14 '23 00:10 github-actions[bot]

Still valid from as far as I know

henri-tremblay avatar Oct 14 '23 01:10 henri-tremblay