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

import-jdl command fails when jdl contains a relationship to User entity in applications with webflux that uses sql db with r2dbc #18293

Closed erycoking closed 2 years ago

erycoking commented 2 years ago
Overview of the issue

import-jdl command fails when jdl contains a relationship to User entity in applications with webflux that uses sql db with r2dbc

Motivation for or Use Case

Unable to import-jdl for applications with relationship to user entity

Reproduce the error

entity Post { title String required content TextBlob required date Instant required }

entity Tag { name String required minlength(2) }

entity Product { title String required price BigDecimal required min(0) image ImageBlob }

relationship ManyToOne { Blog{user(login)} to User Post{blog(name)} to Blog }

relationship ManyToMany { Post{tag(name)} to Tag{post} }

paginate Post, Tag with infinite-scroll paginate Product with pagination

- run the following jhipster command (assuming you named your jdl file as `app-jdl.jdl`)

jhipster import-jdl app-jdl.jdl



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

<!--
Which version of JHipster are you using, is it a regression?
-->
v7.8.0
##### **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.
---
If you have a JDL please wrap it in below structure
  <details>
  <summary>JDL definitions</summary>
  <pre>
     JDL content here
  </pre>
  </details>
-->

<details>
  <summary>JDL definitions</summary>
  <pre>
     ##### **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": "jwt",
    "baseName": "blog",
    "blueprints": [],
    "buildTool": "gradle",
    "cacheProvider": "no",
    "clientFramework": "angularX",
    "clientPackageManager": "npm",
    "clientTheme": "flatly",
    "clientThemeVariant": "primary",
    "creationTimestamp": 1649012211769,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 4200,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entitySuffix": "",
    "jhiPrefix": "blg",
    "jhipsterVersion": "7.8.0",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en", "fr"],
    "messageBroker": false,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageName": "com.blog",
    "pages": [],
    "prodDatabaseType": "postgresql",
    "reactive": true,
    "searchEngine": false,
    "serverPort": "8080",
    "serverSideOptions": [],
    "serviceDiscoveryType": "eureka",
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "skipUserManagement": false,
    "testFrameworks": [],
    "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 Blog {
  name String required minlength(3)
  handle String required minlength(2)
}

entity Post {
  title String required
  content TextBlob required
  date Instant required
}

entity Tag {
  name String required minlength(2)
}

entity Product {
  title String required
  price BigDecimal required min(0)
  image ImageBlob
}

relationship ManyToOne {
  Blog{user(login)} to User
  Post{blog(name)} to Blog
}

relationship ManyToMany {
  Post{tag(name)} to Tag{post}
}

paginate Post, Tag with infinite-scroll
paginate Product with pagination

</pre>
</details>

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

openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)

git version 2.25.1

node: v14.19.0

npm: 6.14.16

Docker version 20.10.14, build a224086

docker-compose version 1.27.4, build 40524192

No change to package.json was detected. No package manager install will be executed.

  </pre>
  </details>

##### **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.
-->

##### **Example of the error produced**
![image](https://user-images.githubusercontent.com/15836962/161831758-14f5bfde-ce73-4c1a-95ee-4d4bc592a0dc.png)

##### **Browsers and Operating System**

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

- [ ] 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 -->
mraible commented 2 years ago

FWIW, I was able to reproduce this problem and asked @erycoking to enter this as an issue. For reference, here's the Stack Overflow Q & A. https://stackoverflow.com/questions/71729575/jhipster-import-jdl-error-in-jhipster-monolith-app-when-jdl-has-user-entity-rela

mshima commented 2 years ago

I will take a look

erycoking commented 2 years ago

This issue is still there. Is the fix live in the current version? @mraible @mshima

mshima commented 2 years ago

Main branch only. npm install -g jhipster/generator-jhipster

erycoking commented 2 years ago

@mshima Thanks for the quick reply.

I uninstalled the old version by running npm un -g generator-jhipster

and installed the new version by running npm install -g jhipster/generator-jhipster

I deleted the old blog project and reinstalled with the new jhipster version. I added the same app-jdl.jdl and run jhipster import-jdl app-jdl.jdl and I am still getting an error

image image

Kindly advice

mshima commented 2 years ago

jhipster import-jdl app-jdl.jdl --prefer-global JHipster uses locally installed jhipster by default.

erycoking commented 2 years ago

@mshima ok. let me try... we inform you if it succeeds

erycoking commented 2 years ago

@mshima Awesome, thanks a lot. it succeeded.

Just wondering, what should I do in order for the local one to be the same as the global one

mshima commented 2 years ago

npm install jhipster/generator-jhipster

erycoking commented 2 years ago

Thanks

Mohammed-5253 commented 2 years ago

Using jhipster/generator-jhipster creates the entity successfully but fails generating admin app. I am getting bunch of errors ./gradlew command:


ERROR in ./src/main/webapp/app/shared/error/error-boundary-route.tsx 14:27-33
TS2322: Type '{ render: (props: any) => Element; caseSensitive?: boolean; children?: ReactNode; element?: ReactNode; index?: boolean; path?: string; }' is not assignable to type 'IntrinsicAttributes & (PathRouteProps | LayoutRouteProps | IndexRouteProps)'.
  Property 'render' does not exist on type 'IntrinsicAttributes & (PathRouteProps | LayoutRouteProps | IndexRouteProps)'.
    12 |   if (!Component) throw new Error(`A component needs to be specified for path ${(rest as any).path}`);
    13 |
  > 14 |   return <Route {...rest} render={encloseInErrorBoundary} />;
       |                           ^^^^^^
    15 | };
    16 |
    17 | export default ErrorBoundaryRoute;

ERROR in ./src/main/webapp/app/shared/layout/header/header.spec.tsx 42:19-26
TS2322: Type '{ children: Element; history: MemoryHistory; }' is not assignable to type 'IntrinsicAttributes & RouterProps'.
  Property 'history' does not exist on type 'IntrinsicAttributes & RouterProps'.
    40 |       const { container } = render(
    41 |         <Provider store={store}>
  > 42 |           <Router history={history}>
       |                   ^^^^^^^
    43 |             <Header {...props} />
    44 |           </Router>
    45 |         </Provider>

I think @types/react-router-dom does not have type definitions for react-router-dom@6.x. Any workarounds?

mshima commented 2 years ago

@DanielFran bounty claimed https://opencollective.com/generator-jhipster/expenses/102423

DanielFran commented 2 years ago

@mshima approved