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.32k stars 4.01k forks source link

Custom column id as UUID for oracle database #25973

Open romarioliveira25 opened 2 months ago

romarioliveira25 commented 2 months ago
Overview of the issue

When using the annotation @id to define a custom column id as UUID in Oracle Database, the generator create liquibase changelogs with column type ${uuidType}. With this, liquibase generate table column with type RAW(16), instead of VARCHAR2(100) as occurs with jHipster built in entities.

Motivation for or Use Case

Turn UUID a pattern for column id of all entities like is in jHipster built in entities.

Reproduce the error
@dto(mapstruct)
entity Area {
    // Need update changelog type from uuid to varchar(100)
    // Liquibase change uuid to raw at oracle database
    @Id id UUID
    nome String required
    ordem Integer required
    slug String required
}
Related issues

Suggest a Fix

By now, I have no code to fix it, but the expected behavior would be as occurs with jHipster built in entities, the use custom id columns

JHipster Version(s)

8.3.0

JHipster configuration
<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "oauth2",
    "baseName": "integra",
    "blueprints": [
      {
        "name": "generator-jhipster-migrate",
        "version": "1.0.0"
      }
    ],
    "buildTool": "maven",
    "cacheProvider": "ehcache",
    "clientFramework": "angular",
    "clientTestFrameworks": [
      "cypress"
    ],
    "clientTheme": "none",
    "creationTimestamp": 1710166091700,
    "cypressAudit": true,
    "cypressCoverage": true,
    "databaseType": "sql",
    "devDatabaseType": "oracle",
    "devServerPort": 4200,
    "enableGradleEnterprise": null,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": [
      "SistemaUser",
      "Historico",
      "Area",
      "Sistema",
      "ControleAcesso"
    ],
    "feignClient": false,
    "gradleEnterpriseHost": null,
    "jhipsterVersion": "8.3.0",
    "languages": [
      "en",
      "pt-br"
    ],
    "lastLiquibaseTimestamp": 1710166211000,
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "en",
    "packageName": "mp.mpro.integra",
    "prodDatabaseType": "oracle",
    "reactive": false,
    "searchEngine": false,
    "serverPort": null,
    "serverSideOptions": [],
    "serviceDiscoveryType": false,
    "skipUserManagement": true,
    "syncUserWithIdp": true,
    "testFrameworks": [
      "cypress"
    ],
    "websocket": false,
    "withAdminUi": true
  }
}
</pre>
</details>
<details>
  <summary>JDL definitions</summary>
  <pre>
  @dto(mapstruct)
  entity Area {
      // Need update changelog type from uuid to varchar(100)
      // Liquibase change uuid to raw at oracle database
      @Id id UUID
      nome String required
      ordem Integer required
      slug String required
  }
  </pre>
  </details>
Entity configuration(s) entityName.json files generated in the .jhipster directory
{
  "annotations": {
    "changelogDate": "20240311140911",
    "dto": "mapstruct"
  },
  "applications": "*",
  "fields": [
    {
      "fieldName": "id",
      "fieldType": "UUID",
      "options": {
        "id": true
      }
    },
    {
      "fieldName": "nome",
      "fieldType": "String",
      "fieldValidateRules": ["required"]
    },
    {
      "fieldName": "ordem",
      "fieldType": "Integer",
      "fieldValidateRules": ["required"]
    },
    {
      "fieldName": "slug",
      "fieldType": "String",
      "fieldValidateRules": ["required"]
    }
  ],
  "name": "Area",
  "relationships": [
    {
      "otherEntityName": "sistema",
      "otherEntityRelationshipName": "area",
      "relationshipName": "sistema",
      "relationshipSide": "left",
      "relationshipType": "one-to-many"
    }
  ],
  "searchEngine": "no"
}
Browsers and Operating System

Ubuntu 22.04 Google Chrome 124.0.6367.60

mshima commented 1 month ago

@romarioliveira25 can you provide a PR?

romarioliveira25 commented 1 month ago

@romarioliveira25 can you provide a PR?

I can try, but probably need some help about wich template files define it.

mshima commented 1 month ago

https://github.com/jhipster/generator-jhipster/blob/4a4264424031f000925f589113b131643d6cf271/generators/liquibase/templates/src/main/resources/config/liquibase/master.xml.ejs#L59

romarioliveira25 commented 1 month ago

https://github.com/jhipster/generator-jhipster/blob/4a4264424031f000925f589113b131643d6cf271/generators/liquibase/templates/src/main/resources/config/liquibase/master.xml.ejs#L59

thx @mshima, i'm looking for initial_schema_sql.xml.ejs, and could not find where is defined idField.columnType, for understand why user built-in column id is type VARCHAR(100) and columns for custom entity generated with the ${uuidType} on databases like MySQL are set with the type VARCHAR(36).

https://github.com/jhipster/generator-jhipster/blob/d173518767475776ecd607e7e4aee5c664d3892e/generators/liquibase/templates/src/main/resources/config/liquibase/changelog/initial_schema_sql.xml.ejs#L47 https://github.com/jhipster/generator-jhipster/blob/d173518767475776ecd607e7e4aee5c664d3892e/generators/liquibase/templates/src/main/resources/config/liquibase/changelog/initial_schema_sql.xml.ejs#L50 https://github.com/jhipster/generator-jhipster/blob/d173518767475776ecd607e7e4aee5c664d3892e/generators/liquibase/templates/src/main/resources/config/liquibase/master.xml.ejs#L27

Can you provide some help about that also?