Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong name and type on findById generation #16531

Closed
1 task done
roneliocronapp opened this issue Oct 3, 2021 · 6 comments
Closed
1 task done

Wrong name and type on findById generation #16531

roneliocronapp opened this issue Oct 3, 2021 · 6 comments

Comments

@roneliocronapp
Copy link

Overview of the issue

When you specify a type other than "Long", the JDL utility overrides the method to "Long" instead of preserving the entered type.

Motivation for or Use Case

Since jhipster supports name definition for primary keys, the name provided must be in all generated code.

Note that some parts have the given name and others are not.

Reproduce the error

Create a jdl file with:

entity CategoriaServico {
@id codigo Long
descricao String required maxlength(50)
}

run jhipster jdl src/main/resources/config/entities.jdl --force

Related issues
Suggest a Fix
JHipster Version(s)
JHipster configuration

INFO! Using JHipster version installed locally in current project's node_modules
7.2.0

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "baseName": "ggg",
    "jhipsterVersion": "7.2.0",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": [],
    "blueprints": [],
    "otherModules": [],
    "pages": [],
    "creationTimestamp": 1633183789805,
    "serviceDiscoveryType": "no",
    "reactive": true,
    "authenticationType": "jwt",
    "packageName": "com.ggg.backend",
    "serverPort": "8080",
    "cacheProvider": "no",
    "enableHibernateCache": false,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "prodDatabaseType": "postgresql",
    "buildTool": "maven",
    "serverSideOptions": ["enableSwaggerCodegen:true"],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": true,
    "clientFramework": "angularX",
    "withAdminUi": true,
    "clientTheme": "litera",
    "clientThemeVariant": "primary",
    "enableTranslation": true,
    "nativeLanguage": "pt-br",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "devServerPort": 4200,
    "clientPackageManager": "npm",
    "languages": ["pt-br", "es"],
    "enableGradleEnterprise": false,
    "entities": ["CategoriaServico", "ChatMessagem", "PlanoServico"],
    "lastLiquibaseTimestamp": 1633267155000
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity CategoriaServico {
  codigo Long
  descricao String required maxlength(50)
}
entity ChatMessagem {
  codigo UUID
  servicoCodigo UUID required
  usuarioEnviado UUID required
  usuarioRecebido UUID required
  mensagem TextBlob
  dataCadastro LocalDate
}
entity PlanoServico {
  codigo Long
  descricao String required maxlength(50)
  taxaServico Double required
}

Environment and Tools

openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)

Entity configuration(s) CategoriaServico.json files generated in the .jhipster directory
{
  "name": "CategoriaServico",
  "fields": [
    {
      "fieldName": "codigo",
      "fieldType": "Long",
      "options": {
        "id": true
      }
    },
    {
      "fieldName": "descricao",
      "fieldType": "String",
      "fieldValidateRules": ["required", "maxlength"],
      "fieldValidateRulesMaxlength": "50"
    }
  ],
  "relationships": [],
  "entityTableName": "categoria_servico",
  "dto": "no",
  "pagination": "no",
  "service": "no",
  "jpaMetamodelFiltering": false,
  "fluentMethods": true,
  "readOnly": false,
  "embedded": false,
  "applications": "*",
  "changelogDate": "20211003021605"
}
Browsers and Operating System
  • Checking this box is mandatory (this is just to show you read everything)
@roneliocronapp
Copy link
Author

I noticed that this problem only occurs when I use "webflux" options.

Primary key with UUID type is always reverted to "Long"
Screen Shot 2021-10-03 at 22 34 20

Primary key with custom name is always reverted to "id"
Screen Shot 2021-10-03 at 22 34 37

@swarajsaaj
Copy link
Contributor

This seems because of hardcoding in following instead of using primaryKey.type:-

Flux<<%= persistClass %>> findAll();
@Override
Mono<<%= persistClass %>> findById(Long id);
@Override
<S extends <%= persistClass %>> Mono<S> save(S entity);

and
@Override
public Mono<<%= persistClass %>> findById(<%= primaryKey.type %> id) {
return createQuery(null, where("id").is(id)).one();
}

This should be fixed, will need to check what impact does it have.

@ronelio
Copy link
Contributor

ronelio commented Oct 6, 2021

OK. I forked and made some changes. That worked!

I'll do more tests and post the result.

@swarajsaaj
Copy link
Contributor

Would you like to do a pull request? :)

@ronelio
Copy link
Contributor

ronelio commented Oct 7, 2021

Fixed some hard-coded references, but I've seen many others at tables join scripts.

I'll keeping coding and fix what I have found.

@swarajsaaj
Copy link
Contributor

I think #16603 fixes this issue.

@mshima mshima closed this as completed Oct 11, 2021
@pascalgrimaud pascalgrimaud added this to the 7.4.0 milestone Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants