profile
viewpoint

Ask questionsjHipster 6.0.0: wrong fake data breaks Liquibase, app

<!--

  • Please follow the issue template below for bug reports.
  • If you have a support request rather than a bug, please use Stack Overflow with the JHipster tag.
  • For bug reports it is mandatory to run the command jhipster info in your project's root folder, and paste the result here.
  • Tickets opened without any of these pieces of information will be closed without any explanation. -->
Overview of the issue

For my Angular / H2 monolith, jHipster generates fake data with a column that's not in my data model. Liquibase and the app fail starting up.

The application does not start up:

2019-05-10 08:16:58.326  WARN 7326 --- [-11-test-task-1] i.g.j.c.liquibase.AsyncSpringLiquibase   : Starting Liquibase asynchronously, your database might not be ready at startup!
2019-05-10 08:17:00.187 ERROR 7326 --- [-11-test-task-1] liquibase.changelog.ChangeSet            : Change Set config/liquibase/changelog/20190510044557_added_entity_Product.xml::20190510044557-1-data::jhipster failed.  Error: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "ORDER_ID" not found; SQL statement:
INSERT INTO PUBLIC.product(id, name, price, description, picture, picture_content_type, bpf_specification, bpf_specification_content_type, category, inventory, order_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [42122-199]
2019-05-10 08:17:00.190 ERROR 7326 --- [-11-test-task-1] i.g.j.c.liquibase.AsyncSpringLiquibase   : Liquibase could not start correctly, your database is NOT ready: Migration failed for change set config/liquibase/changelog/20190510044557_added_entity_Product.xml::20190510044557-1-data::jhipster:
     Reason: liquibase.exception.DatabaseException: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "ORDER_ID" not found; SQL statement:
INSERT INTO PUBLIC.product(id, name, price, description, picture, picture_content_type, bpf_specification, bpf_specification_content_type, category, inventory, order_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [42122-199]

liquibase.exception.MigrationFailedException: Migration failed for change set config/liquibase/changelog/20190510044557_added_entity_Product.xml::20190510044557-1-data::jhipster:
     Reason: liquibase.exception.DatabaseException: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "ORDER_ID" not found; SQL statement:
INSERT INTO PUBLIC.product(id, name, price, description, picture, picture_content_type, bpf_specification, bpf_specification_content_type, category, inventory, order_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [42122-199]
	at liquibase.changelog.ChangeSet.execute(ChangeSet.java:637)
	at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
	at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:83)
	at liquibase.Liquibase.update(Liquibase.java:202)
	at liquibase.Liquibase.update(Liquibase.java:179)
	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:353)
	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:305)
	at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:100)
	at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$0(AsyncSpringLiquibase.java:80)
	at io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$1(ExceptionHandlingAsyncTaskExecutor.java:68)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: liquibase.exception.DatabaseException: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "ORDER_ID" not found; SQL statement:
INSERT INTO PUBLIC.product(id, name, price, description, picture, picture_content_type, bpf_specification, bpf_specification_content_type, category, inventory, order_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [42122-199]
	at liquibase.database.jvm.JdbcConnection.prepareStatement(JdbcConnection.java:320)
	at liquibase.database.PreparedStatementFactory.create(PreparedStatementFactory.java:28)
	at liquibase.statement.ExecutablePreparedStatementBase.execute(ExecutablePreparedStatementBase.java:79)
	at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:115)
	at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1229)
	at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1211)
	at liquibase.changelog.ChangeSet.execute(ChangeSet.java:600)
	... 12 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "ORDER_ID" not found; SQL statement:
INSERT INTO PUBLIC.product(id, name, price, description, picture, picture_content_type, bpf_specification, bpf_specification_content_type, category, inventory, order_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [42122-199]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:451)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
	at org.h2.message.DbException.get(DbException.java:205)
	at org.h2.message.DbException.get(DbException.java:181)
	at org.h2.table.Table.getColumn(Table.java:708)
	at org.h2.command.Parser.parseColumn(Parser.java:1377)
	at org.h2.command.Parser.parseColumnList(Parser.java:1362)
	at org.h2.command.Parser.parseInsertGivenTable(Parser.java:1731)
	at org.h2.command.Parser.parseInsert(Parser.java:1684)
	at org.h2.command.Parser.parsePrepared(Parser.java:891)
	at org.h2.command.Parser.parse(Parser.java:788)
	at org.h2.command.Parser.parse(Parser.java:760)
	at org.h2.command.Parser.prepareCommand(Parser.java:683)
	at org.h2.engine.Session.prepareLocal(Session.java:627)
	at org.h2.engine.Session.prepareCommand(Session.java:565)
	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1292)
	at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:77)
	at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:349)
	at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:311)
	at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java)
	at liquibase.database.jvm.JdbcConnection.prepareStatement(JdbcConnection.java:318)
	... 18 common frames omitted
2019-05-10 08:17:00.776 DEBUG 7326 --- [  restartedMain] c.b.j.t.j.config.WebConfigurer           : Registering CORS filter
2019-05-10 08:17:00.834  INFO 7326 --- [  restartedMain] c.b.j.t.j.config.WebConfigurer           : Web application configuration, using profiles: swagger
2019-05-10 08:17:00.834 DEBUG 7326 --- [  restartedMain] c.b.j.t.j.config.WebConfigurer           : Initialize H2 console
2019-05-10 08:17:00.838  INFO 7326 --- [  restartedMain] c.b.j.t.j.config.WebConfigurer           : Web application fully configured
2019-05-10 08:17:00.915 DEBUG 7326 --- [  restartedMain] c.b.j.t.j.security.jwt.TokenProvider     : Using a Base64-encoded JWT secret key
2019-05-10 08:17:01.520  WARN 7326 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'addressService' defined in file [/Users/karsten/workspaces/me/services/jump-start-project/newsletter/jhipster-001/jhipster/jhipster-6.0.0-java-11-test/out/production/classes/com/betterprojectsfaster/jhipster/test/jhipster6java11/service/AddressService.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.betterprojectsfaster.jhipster.test.jhipster6java11.service.mapper.AddressMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2019-05-10 08:17:01.524 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.d.ShoppingOrder.orders   : Close successful.
2019-05-10 08:17:01.525 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.domain.Product.orders    : Close successful.
2019-05-10 08:17:01.525 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.domain.Address           : Close successful.
2019-05-10 08:17:01.526 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.domain.ProductOrder      : Close successful.
2019-05-10 08:17:01.526 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.domain.User              : Close successful.
2019-05-10 08:17:01.526 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.domain.Product           : Close successful.
2019-05-10 08:17:01.526 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.domain.Authority         : Close successful.
2019-05-10 08:17:01.527 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.domain.ShoppingOrder     : Close successful.
2019-05-10 08:17:01.527 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.domain.Shipment          : Close successful.
2019-05-10 08:17:01.527 DEBUG 7326 --- [  restartedMain] c.e.c.E.b.j.t.j.domain.User.authorities  : Close successful.
2019-05-10 08:17:01.528 DEBUG 7326 --- [  restartedMain] c.ehcache.core.Ehcache-usersByEmail      : Close successful.
2019-05-10 08:17:01.529 DEBUG 7326 --- [  restartedMain] c.ehcache.core.Ehcache-usersByLogin      : Close successful.
2019-05-10 08:17:01.794 ERROR 7326 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 1 of constructor in com.betterprojectsfaster.jhipster.test.jhipster6java11.service.AddressService required a bean of type 'com.betterprojectsfaster.jhipster.test.jhipster6java11.service.mapper.AddressMapper' that could not be found.


Action:

Consider defining a bean of type 'com.betterprojectsfaster.jhipster.test.jhipster6java11.service.mapper.AddressMapper' in your configuration.


Process finished with exit code 0
Motivation for or Use Case

I have a valid JDL file that jHipster imports without reporting an error. However, the generated fake data is wrong and prevents the application from running.

Reproduce the error
  • Create a new jHipster project with Java 11 by importing my JDL file.
  • Run ./gradlew to start the application.
  • The application will fail to run.
Related issues

<!-- Has a similar issue been reported before? Please search both closed & open issues -->

Suggest a Fix

<!-- If you can't fix the bug yourself, perhaps you can point to what might be causing the problem (line of code or commit) -->

  • Make the fake data generation optional - see #9661.
  • Fix the fake data generation.
JHipster Version(s)

<!-- Which version of JHipster are you using, is it a regression? -->

jHipster 6.0.0, Java 11

JHipster configuration

<!-- To provide all information we need, you should run jhipster info in the project root folder, and copy/paste the result here. The .yo-rc.json file generated in the root folder is mandatory for bug reports. This will help us to replicate the scenario. You should remove any sensitive information like the rememberMe key or the jwtSecretKey key. -->

INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:info
INFO! Options: from-cli: true
Welcome to the JHipster Information Sub-Generator

##### **JHipster Version(s)**

j-hipster-6-java-11-test@0.0.0 /Users/karsten/workspaces/me/services/jump-start-project/newsletter/jhipster-001/jhipster/jhipster-6.0.0-java-11-test └── generator-jhipster@6.0.0



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


<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "jhiPrefix": "bpf",
    "languages": ["en", "de"],
    "messageBroker": false,
    "nativeLanguage": "en",
    "packageName": "com.betterprojectsfaster.jhipster.test.jhipster6java11",
    "packageFolder": "com/betterprojectsfaster/jhipster/test/jhipster6java11",
    "prodDatabaseType": "postgresql",
    "searchEngine": false,
    "serviceDiscoveryType": false,
    "skipClient": false,
    "skipServer": false,
    "testFrameworks": ["protractor", "cucumber"],
    "websocket": "spring-websocket",
    "baseName": "jHipster6Java11Test",
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "buildTool": "gradle",
    "cacheProvider": "ehcache",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "npm",
    "jhipsterVersion": "6.0.0",
    "skipUserManagement": false,
    "serverPort": "8080",
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "clientTheme": "none",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": []
  },
  "entities": ["Product", "Address", "ShoppingOrder", "ProductOrder", "Shipment"]
}

</pre>
</details>


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

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

<pre>
entity Product {
  name String required unique minlength(2) maxlength(90),
  price Float required min(0),
  description TextBlob required,
  picture ImageBlob required,
  specification AnyBlob,
  category ProductCategory,
  inventory Integer required min(0)
}
entity Address {
  addressLine1 String required minlength(2) maxlength(80),
  addressLine2 String minlength(2) maxlength(80),
  city String minlength(2) maxlength(80),
  postalCode String minlength(5) maxlength(5)
}
entity ShoppingOrder {
  name String required unique minlength(2) maxlength(90),
  totalAmount Float min(0),
  ordered ZonedDateTime
}
entity ProductOrder {
  amount Integer required min(0) max(5)
}
entity Shipment {
  shippedAt ZonedDateTime required
}

enum ProductCategory {
  Laptop,
  Desktop,
  Phone,
  Tablet,
  Accessory
}

relationship OneToOne {
  Shipment{order(name) required} to ShoppingOrder{shipment required}
}
relationship OneToMany {
  Product{order required} to ProductOrder{product(name) required},
  ShoppingOrder{orders required} to ProductOrder{overallOrder(name)}
}
relationship ManyToOne {
  Address{user(login) required} to User,
  ShoppingOrder{buyer(login) required} to User,
  ProductOrder{buyer(login) required} to User,
  Shipment{shippedBy(login) required} to User
}

dto Product, Address, ShoppingOrder, ProductOrder, Shipment with mapstruct
service Product, Address, ShoppingOrder, ProductOrder, Shipment with serviceClass

</pre>
</details>


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

openjdk version "1.8.0_202"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_202-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.202-b08, mixed mode)

git version 2.21.0

node: v10.15.3

npm: 6.9.0

Docker version 18.09.2, build 6247962

docker-compose version 1.23.2, build 1110ad01
Entity configuration(s) entityName.json files generated in the .jhipster directory

<!-- If the error is during an entity creation or associated with a specific entity. If you are using JDL, please share that configuration as well. -->

Browsers and Operating System

<!-- What OS are you on? is this a problem with all browsers or only IE8? -->

macOS Mojave 10.14.4

  • [X] 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 -->

jhipster/generator-jhipster

Answer questions ksilz

Two other fake data files also have bugs.

shopping_order: table definition, fake data • Has no orders_id column, but fake data has orders_id column
• Has no shipment_id column, but fake data has shipment_id column

shipment: table definition, fake data
order_id column is unique, but in fake data, rows 9 and 11 have same order_id of 1, 3 and 10 both have 4