Closed damy90 closed 11 months ago
Change your JDL to the following, and it should work:
relationship OneToMany {
Post{user} to User with builtInEntity
}
Many at builtin User side is not supported. The User side is immutable and join table is only supported by many-to-many relationships.
We should provide a better error message.
@mraible Yes I followed the instructions in the error and got a different error. I still decided to include the code without " with builtInEntity" because it's closer to the documentation. So 1 to 1 relationship is not supported either? You have that in an example here: https://www.jhipster.tech/user-entity/ It does not compile successfully.
I think I read somewhere on stackoverflow that one to many relationships FROM User do not work because it's immutable and you shouldn't be able to add a field to reference other entities but why wouldn't I be able to add a link in Posts? I would expect Many to Many to not work. I just tried with many to many.
entity Post {
content String,
}
relationship ManyToMany {
Post{user} to User{post} with builtInEntity
}
It compiled with an error, the site runs but it's broken
ERROR! Error editing file C:\dany\test\user-association-jhipster\src\test\resources\META-INF\spring.factories: Cannot read properties of null (reading 'match') at TypeError: Cannot read properties of null (reading 'match')
at JHipsterServerGenerator.<anonymous> (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/base/support/write-files.mjs:29:32)
at writeCallback (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/base/generator-base.mjs:411:58)
at JHipsterServerGenerator.editFile (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/base/generator-base.mjs:425:16)
at source.addTestSpringFactory (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/server/generator.mjs:291:26)
at SqlGenerator.addTestSpringFactory (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/spring-data-relational/generator.mjs:75:46)
at SqlGenerator.executeTask (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:240:26)
at env.queueTask.once (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:214:56)
at runLoop.add.once (C:\Users\daniel.popov\AppData\Roaming\npm\node_modules\generator-jhipster\node_modules\yeoman-environment\lib\environment.js:1441:34)
at Immediate._onImmediate (C:\Users\daniel.popov\AppData\Roaming\npm\node_modules\generator-jhipster\node_modules\grouped-queue\lib\subqueue.js:48:34)
at process.processImmediate (node:internal/timers:476:21)
Error: Error editing file C:\dany\test\user-association-jhipster\src\test\resources\META-INF\spring.factories: Cannot read properties of null (reading 'match') at TypeError: Cannot read properties of null (reading 'match')
at JHipsterServerGenerator.<anonymous> (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/base/support/write-files.mjs:29:32)
at writeCallback (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/base/generator-base.mjs:411:58)
at JHipsterServerGenerator.editFile (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/base/generator-base.mjs:425:16)
at source.addTestSpringFactory (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/server/generator.mjs:291:26)
at SqlGenerator.addTestSpringFactory (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/spring-data-relational/generator.mjs:75:46)
at SqlGenerator.executeTask (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:240:26)
at env.queueTask.once (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:214:56)
at runLoop.add.once (C:\Users\daniel.popov\AppData\Roaming\npm\node_modules\generator-jhipster\node_modules\yeoman-environment\lib\environment.js:1441:34)
at Immediate._onImmediate (C:\Users\daniel.popov\AppData\Roaming\npm\node_modules\generator-jhipster\node_modules\grouped-queue\lib\subqueue.js:48:34)
at process.processImmediate (node:internal/timers:476:21)
at writeCallback (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/base/generator-base.mjs:419:27)
at JHipsterServerGenerator.editFile (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/base/generator-base.mjs:425:16)
at source.addTestSpringFactory (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/server/generator.mjs:291:26)
at SqlGenerator.addTestSpringFactory (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/spring-data-relational/generator.mjs:75:46)
at SqlGenerator.executeTask (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:240:26)
at env.queueTask.once (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:214:56)
at runLoop.add.once (C:\Users\daniel.popov\AppData\Roaming\npm\node_modules\generator-jhipster\node_modules\yeoman-environment\lib\environment.js:1441:34)
at Immediate.<anonymous> (C:\Users\daniel.popov\AppData\Roaming\npm\node_modules\generator-jhipster\node_modules\grouped-queue\lib\subqueue.js:48:34)
at process.processImmediate (node:internal/timers:476:21)
Translations are broken and I can't log in with the default test users "user" and "admin" Edit: That error probably is not related Edit 2: Ignoring errors when the application works fine, it's probably an issue with the Angular template Edit 3: The many to many relation worked. Apparently trying to generate the project several times or from scratch even after deleting the project can cause problems. You have to change the project name to get around random errors. My list of "test-jshint-#" folders is growing. This seems finnicky sometimes.
Change your JDL to the following, and it should work:
relationship OneToMany { Post{user} to User with builtInEntity }
thanks!
Change your JDL to the following, and it should work:
relationship OneToMany { Post{user} to User with builtInEntity }
Thanks so much !
Overview of the issue
I am trying to associate a post to the currently logged in user but I get errors when I try to generate entities. What I'm trying to do seems similar to examples I see online and the documentation.
Without the association entities will be added successfully and administration pages will be added to the app
https://www.jhipster.tech/user-entity/
Example jdl file
Error:
Following the advice from the error message I tried adding "with builtInEntity". Note, it is not mentioned in the documentation I found.
New error when re-running jhipster to update the admin panel: ERROR! An error occured while running jhipster:bootstrap-application-base#prepareRelationshipsForTemplates ERROR! ERROR! Error at entity Post: could not find the other side of the relationship { "otherEntityName": "user", "relationshipName": "user", "relationshipSide": "left", "relationshipType": "one-to-many", "relationshipWithBuiltInEntity": true, "otherEntity": "[User Entity]", "ownerSide": false, "otherEntityField": "id", "relationshipLeftSide": true, "relationshipRightSide": false, "collection": true, "otherSideReferenceExists": false, "otherEntityIsEmbedded": false } Error: Error at entity Post: could not find the other side of the relationship { "otherEntityName": "user", "relationshipName": "user", "relationshipSide": "left", "relationshipType": "one-to-many", "relationshipWithBuiltInEntity": true, "otherEntity": "[User Entity]", "ownerSide": false, "otherEntityField": "id", "relationshipLeftSide": true, "relationshipRightSide": false, "collection": true, "otherSideReferenceExists": false, "otherEntityIsEmbedded": false } at prepareRelationship (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/base-application/support/prepare-relationship.mjs:83:19) at BootstrapApplicationBase.prepareRelationshipsForTemplates (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/dist/generators/bootstrap-application-base/generator.mjs:210:17) at BootstrapApplicationBase.executeTask (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:240:26) at env.queueTask.once (file:///C:/Users/daniel.popov/AppData/Roaming/npm/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:214:56) at runLoop.add.once (C:\Users\daniel.popov\AppData\Roaming\npm\node_modules\generator-jhipster\node_modules\yeoman-environment\lib\environment.js:1441:34) at Immediate. (C:\Users\daniel.popov\AppData\Roaming\npm\node_modules\generator-jhipster\node_modules\grouped-queue\lib\subqueue.js:48:34)
at process.processImmediate (node:internal/timers:476:21)
ERROR! An error occured while running jhipster:bootstrap-application#prepareEntityDerivedProperties
ERROR! An error occured while running jhipster:bootstrap-application#postPreparingEntities
info KeyStore 'C:\dany\test\user-association-jhipster\src\main\resources\config\tls\keystore.p12' already exists. Leaving unchanged.
ERROR! An error occured while running jhipster:server#writeServerFiles
ERROR! An error occured while running jhipster:angular#writeEntitiesFiles
info Using existing git repository.
ERROR! An error occured while running jhipster:spring-data-relational#addTestSpringFactory
Motivation for or Use Case
I am trying to associate a post to the currently logged in user and generate the administration page for the app
Reproduce the error
Run
jhipster
Add and execute jdl file:
jhipster jdl jhipster-jdl.jdl
/**
jhipster
The 2nd error should appear
JHipster Version(s)
Using JHipster 8 beta, the default installed by npm
I tried downgrading to 7.9.3 but the jhipster command wouldn't work at all after that
JHipster configuration
WARNING! Since JHipster v8, the jhipster command will not use the locally installed generator-jhipster. If you want to execute the locally installed generator-jhipster, run: npx jhipster
██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║ ╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗ ╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝ https://www.jhipster.tech Welcome to JHipster v8.0.0-beta.1
Welcome to the JHipster Information Sub-Generator
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
Environment and Tools
openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7) OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)
git version 2.40.1.windows.1
node: v18.15.0 npm: 9.5.0
'docker' command could not be found
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Congratulations, JHipster execution is complete!
Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryPost.json:
jhipster-jdl.jdl:
Browsers and Operating System
Windows 10 Chrome