Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedded OneToOne relationship generation fails #18017

Closed
tchlyah opened this issue Mar 1, 2022 · 2 comments · Fixed by #18028
Closed

Embedded OneToOne relationship generation fails #18017

tchlyah opened this issue Mar 1, 2022 · 2 comments · Fixed by #18028

Comments

@tchlyah
Copy link
Contributor

tchlyah commented Mar 1, 2022

Overview of the issue

It seems that there is a regression in latest version of JHipster (7.7.0): If the other side of a OneToOne relationship is embedded, the generation fails with the following error:

Error running generator app: TypeError: Cannot read properties of undefined (reading 'name')
TypeError: Cannot read properties of undefined (reading 'name')
    at /Users/tayebchlyah/Projects/jhipster/projects/generator-jhipster/generators/entity/index.js:860:78
    at Array.forEach (<anonymous>)
    at EntityGenerator.processEagerLoadRelationships (/Users/tayebchlyah/Projects/jhipster/projects/generator-jhipster/generators/entity/index.js:853:36)
    at Object.<anonymous> (/Users/tayebchlyah/Projects/jhipster/projects/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1097:23)
    at /Users/tayebchlyah/Projects/jhipster/projects/generator-jhipster/node_modules/run-async/index.js:49:25
    at new Promise (<anonymous>)
    at /Users/tayebchlyah/Projects/jhipster/projects/generator-jhipster/node_modules/run-async/index.js:26:19
    at /Users/tayebchlyah/Projects/jhipster/projects/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1098:9
    at new Promise (<anonymous>)
    at EntityGenerator.executeTask (/Users/tayebchlyah/Projects/jhipster/projects/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1069:12)
    at runLoop.add.once (/Users/tayebchlyah/Projects/jhipster/projects/generator-jhipster/node_modules/yeoman-generator/lib/index.js:1049:14)
    at Immediate.<anonymous> (/Users/tayebchlyah/Projects/jhipster/projects/generator-jhipster/node_modules/grouped-queue/lib/subqueue.js:48:34)
    at processImmediate (node:internal/timers:466:21)
Reproduce the error

Use the JDL below.

Suggest a Fix

A simple fix is to add a check relationship.otherEntity.primaryKey != null to

(relationship.ownerSide && relationship.otherEntity.primaryKey.name !== relationship.otherEntityField);

But since this code didn't change on version 7.7.0 (there was some updates after in the main branche but the issue is the same), I think it is coming from an other change that I couldn't find.

JHipster Version(s)

7.7.0

JHipster configuration
JDL definitions
entity Entity1 {}

@embedded
entity Entity2 {}

relationship OneToOne {
Entity1 to Entity2
}

@tchlyah
Copy link
Contributor Author

tchlyah commented Mar 2, 2022

@mshima can you please take a look ? It's kind of urgent since I can't use the new collections and scope introduced by JHipster 7.7.0! Thanks

@mshima
Copy link
Member

mshima commented Mar 2, 2022

I confirm. I prefer testing embedded instead of primaryKey.
As workaround add @EagerLoad annotation to the relationship, it should not change anything using couchbase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants