jhipster / generator-jhipster-nodejs

A NodeJS blueprint that creates the backend using NestJS
https://www.npmjs.com/package/generator-jhipster-nodejs
Apache License 2.0
257 stars 80 forks source link

Cannot set a value to a OneToOne relation #194

Closed hmarchadour closed 3 years ago

hmarchadour commented 3 years ago

Describe the bug

A OneToOne relation produces a not editable field in entity UX.

To Reproduce Steps to reproduce the behavior:

  1. Go to http://localhost:9000/login login with admin/admin
  2. Go to http://localhost:9000/b Create B
  3. Go to http://localhost:9000/a Create A with a relation to the previous b
  4. There is a A entity in result without the expected relation on B

Expected behavior The relation between A and B should exist.

Screenshots

cap 158 cap 159

Desktop (please complete the following information):

NHipster configuration

JHipster Version(s)
test@0.0.1-SNAPSHOT */jdl/test
├── generator-jhipster@6.8.0 
└─┬ generator-jhipster-nodejs@1.4.0
  └── generator-jhipster@6.8.0  deduped
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "authenticationType": "jwt",
    "cacheProvider": "no",
    "clientFramework": "react",
    "serverPort": "8081",
    "serviceDiscoveryType": false,
    "skipUserManagement": false,
    "baseName": "test",
    "buildTool": "maven",
    "databaseType": "sql",
    "devDatabaseType": "sqlite",
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "jhiPrefix": "jhi",
    "languages": ["en", "fr"],
    "messageBroker": false,
    "nativeLanguage": "fr",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "skipClient": false,
    "testFrameworks": ["protractor"],
    "websocket": false,
    "applicationType": "monolith",
    "packageName": "com.jhipster.node",
    "packageFolder": "com/jhipster/node",
    "clientPackageManager": "yarn",
    "blueprint": "generator-jhipster-nodejs",
    "jhipsterVersion": "6.8.0",
    "creationTimestamp": 1609167540593,
    "skipServer": false,
    "clientTheme": "none",
    "clientThemeVariant": "",
    "useSass": true,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "embeddableLaunchScript": false,
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "1.4.0"
      }
    ],
    "blueprints": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "1.4.0"
      }
    ]
  },
  "entities": ["A", "B"]
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity A
entity B
relationship OneToOne {
  A{b} to B{a}
}

Environment and Tools

java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

git version 2.19.0

node: v14.15.3

npm: 6.14.9

yeoman: 3.1.1

yarn: 1.22.10

Docker version 19.03.13, build 4484c46d9d

docker-compose version 1.27.4, build 40524192

Additional context Nothing.

hmarchadour commented 3 years ago

A workaround : Use OneToMany and don't use bidirectional injected fields.

relationship OneToMany {
  A to B{a}
}
ghost commented 3 years ago

Hi @hmarchadour, thanks for the feedback! So it's right that you cannot edit the field, due that a one to one relationship from a custom entity to the User entity, links your field with its primary key that is an autogenerated id (therefore not editable). Instead if you change the relationship with a OneToMany, you can choose a field that isn't a primary key.

ghost commented 3 years ago

The ticket can be considered resolved. So I close it. Thanks in advice for every question and contribution.