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

Fix JdbcSQLIntegrityConstraintViolationException on jhipster-gradle-sample-application when running integration tests #19687

Closed jprinet closed 2 years ago

jprinet commented 2 years ago
Overview of the issue

I discovered some integration test failures on the latest commit of the jhipster-sample-app-gradle

Here is a build scan demonstrating the issue (JdbcSQLIntegrityConstraintViolationException)

Motivation for or Use Case

build failure

Reproduce the error

You can reproduce with ./gradlew clean test integrationTest -x webapp -x webapp_test

Suggest a Fix

Here is a build scan with H2 forced to 1.4.200 which fixes the issue.

The downgrade is not strictly required but this version makes the tests pass See this for details .

JHipster Version(s)

7.9.3

JHipster configuration

❯ jhipster info INFO! Using JHipster version installed globally Welcome to the JHipster Information Sub-Generator

JHipster Version(s)

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**

<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "session",
    "baseName": "jhipsterGradleSampleApplication",
    "blueprints": [],
    "buildTool": "gradle",
    "cacheProvider": "ehcache",
    "clientFramework": "angularX",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "clusteredHttpSession": false,
    "creationTimestamp": 1577000956924,
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "devServerPort": 4200,
    "dtoSuffix": "DTO",
    "embeddableLaunchScript": false,
    "enableGradleEnterprise": true,
    "enableHibernateCache": true,
    "enableSocialSignIn": false,
    "enableTranslation": true,
    "entities": ["BankAccount", "Label", "Operation"],
    "entitySuffix": "",
    "gradleEnterpriseHost": "https://ge.jhipster.tech",
    "hibernateCache": "ehcache",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.9.3",
    "languages": ["en"],
    "messageBroker": false,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageFolder": "io/github/jhipster/sample",
    "packageName": "io.github.jhipster.sample",
    "pages": [],
    "prodDatabaseType": "mysql",
    "reactive": false,
    "rememberMeKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "searchEngine": false,
    "serverPort": 8080,
    "serviceDiscoveryType": false,
    "skipCheckLengthOfIdentifier": false,
    "skipClient": false,
    "skipFakeData": false,
    "skipServer": false,
    "skipUserManagement": false,
    "testFrameworks": ["gatling", "cypress"],
    "useCompass": false,
    "useSass": true,
    "websocket": false,
    "withAdminUi": true
  }
}

</pre>
</details>

##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>
entity BankAccount {
  name String required
  balance BigDecimal required
}
entity Label {
  label String required minlength(3)
}
entity Operation {
  date Instant required
  description String
  amount BigDecimal required
}
relationship OneToMany {
  BankAccount{operation} to Operation{bankAccount(name)}
}
relationship ManyToOne {
  BankAccount{user(login)} to User
}
relationship ManyToMany {
  Operation{label(label)} to Label{operation}
}

paginate Operation with infinite-scroll

</pre>
</details>

##### **Environment and Tools**

openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment Temurin-11.0.12+7 (build 11.0.12+7)
OpenJDK 64-Bit Server VM Temurin-11.0.12+7 (build 11.0.12+7, mixed mode)

git version 2.33.0

node: v17.0.1

npm: 8.7.0

Docker version 20.10.17, build 100c701

Docker Compose version v2.6.1

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

MacOs or Linux

jprinet commented 2 years ago

as per @mshima suggestion, overriding the datasource url with extra MODE=MySQL in application-testdev.yml fixes the issue but I'm not quite sure how to implement this in the generator.

Adding url: jdbc:h2:mem:jhipstergradlesampleapplication;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL at this line would work in my case but should that be retricted to h2InMemory?

jprinet commented 2 years ago

Is there a plan to re-generate the jhipster-sample-app-gradle as the integration tests will keep failing until getting this fix?

atomfrede commented 2 years ago

The app is usually regenerated automatically on the next Release

mshima commented 2 years ago

Added to 7.9.4 milestone as a candidate for backporting.