Skip to content

fix: export-jdl preserves destination-side relationship annotations#32662

Merged
mshima merged 1 commit intojhipster:mainfrom
model-driven-development:fix/relationship-destination-annotation
Mar 12, 2026
Merged

fix: export-jdl preserves destination-side relationship annotations#32662
mshima merged 1 commit intojhipster:mainfrom
model-driven-development:fix/relationship-destination-annotation

Conversation

@trifonnt
Copy link
Contributor

@trifonnt trifonnt commented Mar 11, 2026

Summary

  • Destination-side relationship annotations were lost during export-jdl because getDestinationEntitySideAttributes() never extracted options from the matched right-side relationship
  • Now extracts and maps destination relationship options into JDLRelationship.options.destination

Example

JDL example that demonstrates the fix:

// Before the fix, @CustomTag annotation was lost during export-jdl round-trip

entity Author {
  name String
}
entity Book {
  title String
}
relationship OneToMany {
  Author{book} to @CustomTag Book{author}
}

The @CustomTag on the destination side (Book) would be silently dropped when running jhipster export-jdl. After the fix, it is now preserved.

Closes #32655

Test plan

  • Added unit test for destination-side relationship options in json-to-jdl-entity-converter.spec.ts
  • Added options: { destinationAnnotation: true } to right-side relationship in export-jdl.spec.ts
  • All 30 tests passing, snapshots updated

Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (below reviewers) and adding skip-ci label, you can still see CI build result at your branch.

Copilot AI review requested due to automatic review settings March 11, 2026 20:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes export-jdl so that relationship annotations/options defined on the destination (right) side of a bidirectional relationship are preserved when converting JSON entities back into JDL.

Changes:

  • Extract destination-side relationship options from the matched right-side relationship entry.
  • Map those extracted options into JDLRelationship.options.destination during JSON → JDL conversion.
  • Extend unit/integration coverage and update snapshots to assert destination-side annotations appear in exported JDL.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
lib/jdl/converters/json-to-jdl-entity-converter.ts Maps right-side relationship options into JDLRelationship.options.destination when constructing the merged relationship.
lib/jdl/converters/json-to-jdl-entity-converter.spec.ts Adds a unit test asserting destination-side relationship options are parsed into options.destination.
generators/export-jdl/export-jdl.spec.ts Adds options to a right-side relationship fixture to validate end-to-end behavior.
generators/export-jdl/snapshots/export-jdl.spec.ts.snap Updates snapshots to confirm destination annotations render on the destination entity side in the exported JDL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@mshima mshima merged commit 44e25d9 into jhipster:main Mar 12, 2026
63 of 64 checks passed
@trifonnt trifonnt deleted the fix/relationship-destination-annotation branch March 12, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants