generator-jhipster: UUID id fields generate autoincrement attribute which fails application startup

Overview of the issue

For id fields having UUID type, the generator generates autoIncrement="true" in my configuration, even though during startup of such an application, an error is being produced:

This is produced in the liquibase entity changelog for adding the field

            <column name="uuid" type="${uuidType}" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>

even though in master.xml a varchar field is produced.

    <property name="uuidType" value="varchar(36)" dbms="h2, mysql, mariadb"/>

So during startup, such an error is produced:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [de/mt/dataview/config/LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LiquibaseException: liquibase.exception.UnexpectedLiquibaseException: Property [autoIncrement] was not found for object type [liquibase.datatype.core.VarcharType]
Motivation for or Use Case

Application will not start up.

Reproduce the error
Related issues

#17833

Suggest a Fix

I think, it is related to the reactive branch in this if-else statement:

https://github.com/jhipster/generator-jhipster/blob/2dc5a892a8fbf216f78372058974c663078c822f/utils/field.js#L279-L284

where the liquibaseAutoIncrement value is statically set to true. Seems to be just not considered in d63b9d695573433977473e6503df7e7fc14704f3

JHipster Version(s)

7.6.0 (latest SNAPSHOT now, since other bugs in the last release cover up this one, e.g. #17833, #17823)

JHipster configuration
JHipster Version(s)
dataview@0.0.1-SNAPSHOT C:\Users\jwedding\git\mt\demo3
`-- (empty)

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "oauth2",
    "baseName": "dataview",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "react",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1639736978010,
    "databaseType": "sql",
    "devDatabaseType": "mysql",
    "devServerPort": 9060,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": ["DataStream"],
    "entitySuffix": "",
    "incrementalChangelog": true,
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.6.0",
    "languages": ["de", "en"],
    "lastLiquibaseTimestamp": 1644410794000,
    "messageBroker": false,
    "nativeLanguage": "de",
    "otherModules": [],
    "packageName": "de.mt.dataview",
    "pages": [],
    "prodDatabaseType": "mysql",
    "reactive": true,
    "rememberMeKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "searchEngine": false,
    "serverPort": "8080",
    "serverSideOptions": [],
    "serviceDiscoveryType": "no",
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "skipJhipsterDependencies": true,
    "skipUserManagement": true,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": true
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity DataStream {
  @Id uuid UUID
}
paginate DataStream with pagination
service DataStream with serviceImpl

Environment and Tools

openjdk version “11.0.12” 2021-07-20 LTS OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode)

git version 2.35.1.windows.2

node: v14.18.2

npm: 6.14.15

Docker version 20.10.9, build c2ea9bc

No change to package.json was detected. No package manager install will be executed. Congratulations, JHipster execution is complete!

Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
  • Checking this box is mandatory (this is just to show you read everything)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Ok, will not be enough for UUID (or other types, except now the Long type). It will result in an error when saving a new entity, like this:

org.springframework.dao.TransientDataAccessResourceException: Failed to update table [data_stream]. Row with Id [530e6d0d-7860-4547-a1bd-df4ab705a265] does not exist.

This is because we probably have to generate the Entity with implementation of the Persistable interface (reference https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#is-new-state-detection ) to allow to mark an entity as new… I’ll try to include this in my Pull Request then. 😃

This may then also resolve #14569, as also suggested in https://github.com/jhipster/generator-jhipster/issues/14569#issuecomment-828419358