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

💥 Incorrect Object Type is being passed as parameter #15042

Closed
1 task done
amatosg opened this issue May 20, 2021 · 10 comments · Fixed by #23234
Closed
1 task done

💥 Incorrect Object Type is being passed as parameter #15042

amatosg opened this issue May 20, 2021 · 10 comments · Fixed by #23234

Comments

@amatosg
Copy link
Contributor

amatosg commented May 20, 2021

Overview of the issue

When creating a reactive monolithic project, setting the entity as UUID and importing through a JDL file, the method in the EntityRepository interface has the incorrect object type as parameter:

@Override
Mono<Bank> findById(Long id);

instead of

@Override
Mono<Bank> findById(UUID id);
Motivation for or Use Case

This creates the wrong method signature.

Reproduce the error
  1. Create an entity like
entity Bank {
  id UUID,
  surrogateId Long,
	name String required minlength(3),
  phone String,
  address String,
  bic String,
  swift String,
  active Boolean
}
  1. Import project with jhipster import-jdl bank.jh
  2. Open BankRepository interface
Related issues

None that I know of.

Suggest a Fix

Change the signature using the proper object type

JHipster Version(s)

v7.0.1

JHipster configuration
JDL definitions
     {
  "generator-jhipster": {
    "blueprints": [],
    "otherModules": [],
    "applicationType": "monolith",
    "baseName": "myapp",
    "jhipsterVersion": "7.0.1",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": true,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": ["cucumber"],
    "pages": [],
    "creationTimestamp": 1621302585599,
    "serviceDiscoveryType": false,
    "reactive": true,
    "authenticationType": "oauth2",
    "packageName": "com.myapp",
    "serverPort": "8080",
    "cacheProvider": "no",
    "enableHibernateCache": false,
    "databaseType": "sql",
    "devDatabaseType": "postgresql",
    "prodDatabaseType": "postgresql",
    "buildTool": "maven",
    "serverSideOptions": [],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "angularX",
    "withAdminUi": true,
    "clientTheme": "spacelab",
    "clientThemeVariant": "primary",
    "enableTranslation": false,
    "nativeLanguage": "es",
    "packageFolder": "com/facturapp",
    "clientPackageManager": "npm",
    "languages": ["en", "fr"],
    "entities": [
      "Bank"
    ],
    "lastLiquibaseTimestamp": 1621472187000
  }
}
  
Entity configuration(s) entityName.json files generated in the .jhipster directory
Entity Configuration
{
  "name": "Bank",
  "fields": [
    {
      "fieldName": "id",
      "fieldType": "UUID"
    },
    {
      "fieldName": "surrogateId",
      "fieldType": "Long"
    },
    {
      "fieldName": "name",
      "fieldType": "String",
      "fieldValidateRules": ["required", "minlength"],
      "fieldValidateRulesMinlength": "3"
    },
    {
      "fieldName": "phone",
      "fieldType": "String"
    },
    {
      "fieldName": "address",
      "fieldType": "String"
    },
    {
      "fieldName": "bic",
      "fieldType": "String"
    },
    {
      "fieldName": "swift",
      "fieldType": "String"
    },
    {
      "fieldName": "active",
      "fieldType": "Boolean"
    }
  ],
  "relationships": [
  ],
  "entityTableName": "bank",
  "dto": "mapstruct",
  "pagination": "pagination",
  "service": "serviceImpl",
  "jpaMetamodelFiltering": false,
  "fluentMethods": true,
  "readOnly": false,
  "embedded": false,
  "applications": "*",
  "changelogDate": "20210520005604"
}
  
Browsers and Operating System

Using Windows 10 and Brave Browser

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

Love JHipster? Please consider supporting our collective:
👉 https://opencollective.com/generator-jhipster/donate

@amatosg
Copy link
Contributor Author

amatosg commented May 20, 2021

Also, class EntityManager is missing 2 methods:
public Mono<Integer> updateLinkTable(LinkTable table, UUID entityId, Stream<UUID> referencedIds) and
public Mono<Void> deleteFromLinkTable(LinkTable table, UUID entityId)

@atomfrede
Copy link
Member

Looks like a bug. Here

should be <%= primaryKey.type %> used instead of Long.

@DanielFran
Copy link
Member

DanielFran commented Jun 16, 2021

And also here:


should be <%= primaryKey.type %> used instead of Long.

@DanielFran
Copy link
Member

DanielFran commented Jun 16, 2021

@amatosg Do you want to contribute with a PR?

@amatosg
Copy link
Contributor Author

amatosg commented Jun 16, 2021

sure, let me take a look at it tonight

@amatosg
Copy link
Contributor Author

amatosg commented Jun 16, 2021

public Mono<Integer> updateLinkTable(LinkTable table, Long entityId, Stream<Long> referencedIds) {

public Mono<Void> deleteFromLinkTable(LinkTable table, Long entityId) {

So I guess those also need to be changed?

@amatosg
Copy link
Contributor Author

amatosg commented Jun 27, 2021

@atomfrede @DanielFran I'm having trouble accessing primaryKey in EntityManager.java.ejs. Any lights on how to import that value?

@mshima
Copy link
Member

mshima commented Jun 27, 2021

It’s not available only default jhipsterConfig.pkType.
primaryKey is specific to an entity, you are using the server generator.
If possible you should use generics or just Object.

@github-actions
Copy link
Contributor

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 😃.
Comment or this will be closed in 7 days

@pascalgrimaud pascalgrimaud added this to the 7.2.0 milestone Sep 11, 2021
@amatosg
Copy link
Contributor Author

amatosg commented Oct 5, 2021

I'm lacking the time to help with this, but I just remember about it. This bug is still present in the code :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants