Generator-jhipster: React and OAuth2: bug with relationship to user

Created on 18 Oct 2020  ·  3Comments  ·  Source: jhipster/generator-jhipster

Overview of the issue

When saving an entity which has relationship to user, and letting user empty, it failed

Motivation for or Use Case

we should be able to save entity without user

Reproduce the error
  • generate an app with React + OAuth2
  • add entity with relationship to user
  • start app
  • save an entity with empty user
Related issues

Related to https://github.com/jhipster/generator-jhipster/pull/12777

Suggest a Fix
JHipster Version(s)

current master

JHipster Version(s)
[email protected] /home/pgrimaud/tmp/28-react-oauth2
└── (empty)

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "blueprints": [],
    "otherModules": [],
    "applicationType": "monolith",
    "reactive": false,
    "baseName": "burger",
    "jhipsterVersion": "6.10.3",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": true,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "clientPackageManager": "npm",
    "testFrameworks": ["cypress"],
    "pages": [],
    "creationTimestamp": 1603014850708,
    "promptValues": {
      "packageName": "io.github.pascalgrimaud",
      "nativeLanguage": "en"
    },
    "serviceDiscoveryType": false,
    "authenticationType": "oauth2",
    "packageName": "io.github.pascalgrimaud",
    "serverPort": "8080",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "buildTool": "maven",
    "serverSideOptions": [],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "react",
    "clientTheme": "none",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "packageFolder": "io/github/pascalgrimaud",
    "clientThemeVariant": "primary",
    "useSass": true,
    "languages": ["en"]
  }
}

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


JDL entity definitions

entity Operation {
  date Instant required
  description String
  amount BigDecimal required
}
entity BankAccount {
  name String required
  guid UUID
  bankNumber Integer
  agencyNumber Long
  lastOperationDuration Float
  meanOperationDuration Double
  meanQueueDuration Duration
  balance BigDecimal required
  openingDay LocalDate
  lastOperationDate Instant
  active Boolean
  accountType BankAccountType
  attachment AnyBlob
  description TextBlob
}
entity Label {
  labelName String required minlength(3)
}
enum BankAccountType {
  CHECKING,
  SAVINGS,
  LOAN
}

relationship OneToMany {
  BankAccount{operation} to Operation{bankAccount(name)}
}
relationship ManyToOne {
  BankAccount{user(login)} to User
}
relationship ManyToMany {
  Operation{label(labelName)} to Label{operation}
}

paginate Operation with infinite-scroll
paginate Label with pagination
clientRootFolder Operation, BankAccount, Label with test-root
dto BankAccount with mapstruct
service BankAccount with serviceImpl
service Label with serviceClass
angularSuffix BankAccount with mySuffix
filter BankAccount
readOnly Label

Environment and Tools

openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)

git version 2.28.0

node: v12.19.0

npm: 6.14.8

yeoman: 3.1.1

Docker version 19.03.8, build afacb8b7f0

docker-compose version 1.27.3, build 4092ae5d

INFO! Congratulations, JHipster execution is complete!

$$ bug-bounty $$ $100 area react relationships

All 3 comments

Good, it's fixed in main branch. Thanks a lot @qmonmert ! Don't forget to claim your bounty

@qmonmert : approved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chegola picture chegola  ·  4Comments

lsadehaan picture lsadehaan  ·  3Comments

sdoxsee picture sdoxsee  ·  4Comments

dronavallisaikrishna picture dronavallisaikrishna  ·  3Comments

frantzynicolas picture frantzynicolas  ·  3Comments