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

PropertyAccessException on Delete and Update Operations for Entities with Enum Fields in JHipster 8.6 #27030

Open djibythiaw opened 3 weeks ago

djibythiaw commented 3 weeks ago
Overview of the issue

I encountered a PropertyAccessException when trying to delete or update an entity that includes enum type fields. The error message is: "Could not set value of type [sn.sonatel.dsi.ftsirc.domain.enumeration.Engagement]: 'sn.sonatel.dsi.ftsirc.domain.Projet.engagementBuild' (setter)". The issue does not occur during the creation or reading of the entity, only during delete and update operations. This problem is related to the handling of enum types in entities generated by JHipster version 8.6.

Motivation for or Use Case

This bug is critical as it disrupts the functionality of delete and update operations on entities containing enum type fields, which are essential operations in most applications.

Reproduce the error
  1. Define an entity with multiple enum fields using JHipster version 8.6. An example JDL:
    entity Projet {
        numProjet String
        title String required
        statutProjet StatutProjet required
        engagementEtude Engagement
        engagementThink Engagement
        engagementBuild Engagement
    }
    enum Engagement {
        T1,
        T2,
        T3,
        T4
    }
  2. Generate the entity using JHipster.
  3. Attempt to delete or update an instance of this entity via the service layer.
  4. Observe the PropertyAccessException being thrown.

Welcome to the JHipster Information Sub-Generator

gdd-backend@0.0.0 /Users/thiaw028551/default-workspace/projects/GDD/gdd-backend
└── (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "microservice",
    "authenticationType": "oauth2",
    "baseName": "GddBackend",
    "buildTool": "maven",
    "cacheProvider": "hazelcast",
    "clientFramework": "no",
    "clientTestFrameworks": null,
    "clientTheme": null,
    "creationTimestamp": 1723193387440,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": [
      "Dashboard",
      "Demande",
      "Domaine",
      "PieceJointe",
      "Projet",
      "Structure",
      "Typologie"
    ],
    "feignClient": false,
    "jhipsterVersion": "8.6.0",
    "languages": [
      "fr"
    ],
    "lastLiquibaseTimestamp": 1724161220000,
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "fr",
    "packageName": "sn.sonatel.dsi.ftsirc",
    "prodDatabaseType": "mysql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": 8081,
    "serverSideOptions": [],
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "skipUserManagement": true,
    "syncUserWithIdp": true,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": null
  }
}
Environment and Tools

java version "21.0.1" 2023-10-17 LTS Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29) Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)

git version 2.37.1

node: v20.16.0 npm: 10.8.1

Docker version 26.1.1, build 4cf5afa

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
@ChangelogDate("20240819142304")
entity Dashboard {
  libelle String required unique
  url TextBlob required
  roles TextBlob required
}
@ChangelogDate("20240819142305")
entity Demande {
  numDemande String
  numEasyvista String
  title String required
  statutTraitement StatutTraitement required
  description TextBlob required
  typeDemande TypeDemande required
  complexite Complexite required
  dateDeCreation ZonedDateTime
  dateDeModification ZonedDateTime
  dateDePriseEnCharge ZonedDateTime
  dateDeLivraisonReel ZonedDateTime
  kickOffPrev ZonedDateTime
  mepPrev ZonedDateTime
  mepReel ZonedDateTime
  kickOffReel ZonedDateTime
  commentaire TextBlob
  debutStandByEtude ZonedDateTime
  finStandByEtude ZonedDateTime
  dateDeReception ZonedDateTime
  debutStandbyIngenieur ZonedDateTime
  finStandByIngenieur ZonedDateTime
  portefeuille String required
  experienceUser NiveauImpact
  impactSurVenteCA NiveauImpact
  impactProcessInterne NiveauImpact
  commentaireCreationDeValeur TextBlob
  etatValidation String
  creationDeValeur String
  priorite Priorite
}
@ChangelogDate("20240819142306")
entity Domaine {
  libelle String
}
@ChangelogDate("20240819142307")
entity PieceJointe {
  libelle String
  spItemId String
  spFieldId Long
  pieceJointeUrl String
}
@ChangelogDate("20240819142308")
entity Projet {
  numProjet String
  title String required
  statutProjet StatutProjet required
  description TextBlob required
  dateDeCreation ZonedDateTime
  dateDeModification ZonedDateTime
  livraisonEtudePrevisionnelle ZonedDateTime
  livraisonEtudeReelle ZonedDateTime
  archiReviewReel ZonedDateTime
  thinkReviewPrev ZonedDateTime
  thinkReviewActualise ZonedDateTime
  thinkReviewReel ZonedDateTime
  designReviewPrev ZonedDateTime
  designReviewReel ZonedDateTime
  buildReviewPrev ZonedDateTime
  buildReviewReel ZonedDateTime
  buildReviewActualise ZonedDateTime
  mepPrev ZonedDateTime
  mepActualise ZonedDateTime
  mepReelle ZonedDateTime
  finalReviewPrev ZonedDateTime
  finalReviewReel ZonedDateTime
  commentaire TextBlob
  archiReviewPrevisionnel TextBlob
  experienceUser NiveauImpact
  impactSurVenteCA NiveauImpact
  impactProcessInterne NiveauImpact
  impactImage NiveauImpact
  creationDeValeur String
  engagementEtude Engagement
  engagementThink Engagement
  engagementBuild Engagement
}
@ChangelogDate("20240819142309")
entity Structure {
  libelle String
  typeStructure TypeStructure
}
@ChangelogDate("20240819142310")
entity Typologie {
  libelle String
}

enum StatutTraitement {
  EN_INSTANCE,
  QUALIFIE,
  DEPRIORISE,
  TRANSFERE,
  REJETE,
  EN_ATTENTE_CLIENT,
  ANNULE,
  STAND_BY,
  EN_COURS_INGENIERIE,
  EN_COURS_ETUDE,
  TERMINE
}
enum TypeDemande {
  EVOLUTION,
  PARAMETRAGE_METIER
}
enum Complexite {
  TRES_SIMPLE,
  SIMPLE,
  MOYENNE,
  COMPLEXE,
  TRES_COMPLEXE
}
enum NiveauImpact {
  TRES_FAIBLE,
  FAIBLE,
  MODERE,
  FORT,
  TRES_FORT
}
enum Priorite {
  P0,
  P1,
  P2,
  P3,
  P4,
  P5
}
enum StatutProjet {
  EN_COURS_ETUDE,
  ETUDE_OPPORTUNITE_VALIDE,
  THINK_VALIDE,
  EN_COURS_MISE_EN_OEUVRE,
  BUILD_VALIDE,
  DEPRIORISE,
  EN_STAND_BY,
  ANNULE,
  DOSSIER_ETUDE_VALIDE,
  NON_DEMARRE,
  TERMINE
}
enum Engagement {
  T1,
  T2,
  T3,
  T4
}
enum TypeStructure {
  DIRECTION,
  POLE,
  DEPARTEMENT,
  SERVICE
}

relationship ManyToOne {
  Demande{beneficiaire(login)} to User with builtInEntity
  Demande{demandeur(login)} to User with builtInEntity
  Demande{createdBy(login)} to User with builtInEntity
  Demande{updatedBy(login)} to User with builtInEntity
  Demande{structureEtude(libelle)} to Structure
  Demande{structureIngenierie(libelle)} to Structure
  Demande{structureBeneficiaire(libelle)} to Structure
  Demande{domaine(libelle)} to Domaine
  Demande{pieceJointe(libelle)} to PieceJointe
  Projet{archetecteLead(login)} to User with builtInEntity
  Projet{architecteSecurite(login)} to User with builtInEntity
  Projet{architecteInfra(login)} to User with builtInEntity
  Projet{createdBy(login)} to User with builtInEntity
  Projet{updatedBy(login)} to User with builtInEntity
  Projet{admin(login)} to User with builtInEntity
  Projet{exploitant(login)} to User with builtInEntity
  Projet{supervision(login)} to User with builtInEntity
  Projet{typologie(libelle)} to Typologie
  Projet{structureEtude(libelle)} to Structure
  Projet{structureIngenierie(libelle)} to Structure
  Projet{domaine(libelle)} to Domaine
  Projet{pieceJointe(libelle)} to PieceJointe
  Structure{parent(libelle)} to Structure
}
relationship ManyToMany {
  Demande{porteur(login)} to User with builtInEntity
}

dto Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with mapstruct
paginate Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with pagination
service Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with serviceImpl
search Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with no
microservice Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with GddBackend
filter Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie
clientRootFolder Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with GddBackend

Congratulations, JHipster execution is complete! If you find JHipster useful consider sponsoring the project https://www.jhipster.tech/sponsors/

Thanks for using JHipster!

Related issues

After searching the issues, I did not find an exact match for this problem, but it appears to be a potential regression or unintended behavior introduced in version 8.6.

Suggest a Fix

The issue likely stems from how JHipster handles enum types during the generation of entity classes, particularly in the setter methods. A potential fix could involve reviewing and adjusting the handling of enum properties in the generated code.

JHipster Version(s)

The issue occurs in JHipster version 8.6 with java 21

Browsers and Operating System

Operating System: MacOS Browser: Not applicable (Issue occurs server-side)

mshima commented 3 weeks ago

Post the jhipster info output of the sample project in the issue description.

djibythiaw commented 3 weeks ago

Hello,

Receive below the output

Welcome to JHipster v8.6.0

Welcome to the JHipster Information Sub-Generator

gdd-backend@0.0.0 /Users/thiaw028551/default-workspace/projects/GDD/gdd-backend
└── (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "microservice",
    "authenticationType": "oauth2",
    "baseName": "GddBackend",
    "buildTool": "maven",
    "cacheProvider": "hazelcast",
    "clientFramework": "no",
    "clientTestFrameworks": null,
    "clientTheme": null,
    "creationTimestamp": 1723193387440,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": [
      "Dashboard",
      "Demande",
      "Domaine",
      "PieceJointe",
      "Projet",
      "Structure",
      "Typologie"
    ],
    "feignClient": false,
    "jhipsterVersion": "8.6.0",
    "languages": [
      "fr"
    ],
    "lastLiquibaseTimestamp": 1724161220000,
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "fr",
    "packageName": "sn.sonatel.dsi.ftsirc",
    "prodDatabaseType": "mysql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": 8081,
    "serverSideOptions": [],
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "skipUserManagement": true,
    "syncUserWithIdp": true,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": null
  }
}
Environment and Tools

java version "21.0.1" 2023-10-17 LTS Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29) Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, mixed mode, sharing)

git version 2.37.1

node: v20.16.0 npm: 10.8.1

Docker version 26.1.1, build 4cf5afa

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
@ChangelogDate("20240819142304")
entity Dashboard {
  libelle String required unique
  url TextBlob required
  roles TextBlob required
}
@ChangelogDate("20240819142305")
entity Demande {
  numDemande String
  numEasyvista String
  title String required
  statutTraitement StatutTraitement required
  description TextBlob required
  typeDemande TypeDemande required
  complexite Complexite required
  dateDeCreation ZonedDateTime
  dateDeModification ZonedDateTime
  dateDePriseEnCharge ZonedDateTime
  dateDeLivraisonReel ZonedDateTime
  kickOffPrev ZonedDateTime
  mepPrev ZonedDateTime
  mepReel ZonedDateTime
  kickOffReel ZonedDateTime
  commentaire TextBlob
  debutStandByEtude ZonedDateTime
  finStandByEtude ZonedDateTime
  dateDeReception ZonedDateTime
  debutStandbyIngenieur ZonedDateTime
  finStandByIngenieur ZonedDateTime
  portefeuille String required
  experienceUser NiveauImpact
  impactSurVenteCA NiveauImpact
  impactProcessInterne NiveauImpact
  commentaireCreationDeValeur TextBlob
  etatValidation String
  creationDeValeur String
  priorite Priorite
}
@ChangelogDate("20240819142306")
entity Domaine {
  libelle String
}
@ChangelogDate("20240819142307")
entity PieceJointe {
  libelle String
  spItemId String
  spFieldId Long
  pieceJointeUrl String
}
@ChangelogDate("20240819142308")
entity Projet {
  numProjet String
  title String required
  statutProjet StatutProjet required
  description TextBlob required
  dateDeCreation ZonedDateTime
  dateDeModification ZonedDateTime
  livraisonEtudePrevisionnelle ZonedDateTime
  livraisonEtudeReelle ZonedDateTime
  archiReviewReel ZonedDateTime
  thinkReviewPrev ZonedDateTime
  thinkReviewActualise ZonedDateTime
  thinkReviewReel ZonedDateTime
  designReviewPrev ZonedDateTime
  designReviewReel ZonedDateTime
  buildReviewPrev ZonedDateTime
  buildReviewReel ZonedDateTime
  buildReviewActualise ZonedDateTime
  mepPrev ZonedDateTime
  mepActualise ZonedDateTime
  mepReelle ZonedDateTime
  finalReviewPrev ZonedDateTime
  finalReviewReel ZonedDateTime
  commentaire TextBlob
  archiReviewPrevisionnel TextBlob
  experienceUser NiveauImpact
  impactSurVenteCA NiveauImpact
  impactProcessInterne NiveauImpact
  impactImage NiveauImpact
  creationDeValeur String
  engagementEtude Engagement
  engagementThink Engagement
  engagementBuild Engagement
}
@ChangelogDate("20240819142309")
entity Structure {
  libelle String
  typeStructure TypeStructure
}
@ChangelogDate("20240819142310")
entity Typologie {
  libelle String
}

enum StatutTraitement {
  EN_INSTANCE,
  QUALIFIE,
  DEPRIORISE,
  TRANSFERE,
  REJETE,
  EN_ATTENTE_CLIENT,
  ANNULE,
  STAND_BY,
  EN_COURS_INGENIERIE,
  EN_COURS_ETUDE,
  TERMINE
}
enum TypeDemande {
  EVOLUTION,
  PARAMETRAGE_METIER
}
enum Complexite {
  TRES_SIMPLE,
  SIMPLE,
  MOYENNE,
  COMPLEXE,
  TRES_COMPLEXE
}
enum NiveauImpact {
  TRES_FAIBLE,
  FAIBLE,
  MODERE,
  FORT,
  TRES_FORT
}
enum Priorite {
  P0,
  P1,
  P2,
  P3,
  P4,
  P5
}
enum StatutProjet {
  EN_COURS_ETUDE,
  ETUDE_OPPORTUNITE_VALIDE,
  THINK_VALIDE,
  EN_COURS_MISE_EN_OEUVRE,
  BUILD_VALIDE,
  DEPRIORISE,
  EN_STAND_BY,
  ANNULE,
  DOSSIER_ETUDE_VALIDE,
  NON_DEMARRE,
  TERMINE
}
enum Engagement {
  T1,
  T2,
  T3,
  T4
}
enum TypeStructure {
  DIRECTION,
  POLE,
  DEPARTEMENT,
  SERVICE
}

relationship ManyToOne {
  Demande{beneficiaire(login)} to User with builtInEntity
  Demande{demandeur(login)} to User with builtInEntity
  Demande{createdBy(login)} to User with builtInEntity
  Demande{updatedBy(login)} to User with builtInEntity
  Demande{structureEtude(libelle)} to Structure
  Demande{structureIngenierie(libelle)} to Structure
  Demande{structureBeneficiaire(libelle)} to Structure
  Demande{domaine(libelle)} to Domaine
  Demande{pieceJointe(libelle)} to PieceJointe
  Projet{archetecteLead(login)} to User with builtInEntity
  Projet{architecteSecurite(login)} to User with builtInEntity
  Projet{architecteInfra(login)} to User with builtInEntity
  Projet{createdBy(login)} to User with builtInEntity
  Projet{updatedBy(login)} to User with builtInEntity
  Projet{admin(login)} to User with builtInEntity
  Projet{exploitant(login)} to User with builtInEntity
  Projet{supervision(login)} to User with builtInEntity
  Projet{typologie(libelle)} to Typologie
  Projet{structureEtude(libelle)} to Structure
  Projet{structureIngenierie(libelle)} to Structure
  Projet{domaine(libelle)} to Domaine
  Projet{pieceJointe(libelle)} to PieceJointe
  Structure{parent(libelle)} to Structure
}
relationship ManyToMany {
  Demande{porteur(login)} to User with builtInEntity
}

dto Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with mapstruct
paginate Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with pagination
service Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with serviceImpl
search Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with no
microservice Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with GddBackend
filter Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie
clientRootFolder Dashboard, Demande, Domaine, PieceJointe, Projet, Structure, Typologie with GddBackend

Congratulations, JHipster execution is complete! If you find JHipster useful consider sponsoring the project https://www.jhipster.tech/sponsors/

Thanks for using JHipster!

github-actions[bot] commented 3 weeks ago

JHipster has completed the sample check .yo-rc.json: valid Entities JDL: valid Application: successfully generated Frontend check: success Backend check: success E2E check: success

This check uses jhipster info output from the issue description to generate the sample. Bug report that does not contain this information will be marked as invalid.

mshima commented 3 weeks ago

Tests are passing using main branch.