Fix multiplicity=1 for simple type associations in Reader/Writer generators#521
Merged
slachiewicz merged 3 commits intomasterfrom Oct 8, 2025
Merged
Conversation
Copilot
AI
changed the title
[WIP] multiplicity with 1 for simple type generate wrong code in Reader/Writer
Fix multiplicity=1 for simple type associations in Reader/Writer generators
Oct 6, 2025
Member
|
@copilot please rebase on master, fix conflicts and adjust code if needed |
Contributor
Author
Rebased on master successfully. The conflict in JDOMWriterGenerator.java was resolved by updating references from |
gnodet
approved these changes
Oct 8, 2025
slachiewicz
approved these changes
Oct 8, 2025
Co-authored-by: slachiewicz <[email protected]>
…city=1 Co-authored-by: slachiewicz <[email protected]>
… with multiplicity=1 Co-authored-by: slachiewicz <[email protected]>
70d6dc1 to
3a12096
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixing issue with multiplicity=1 for simple type associations in Reader/Writer generators
Summary
The issue was that when an association field has
multiplicity="1"and the type is a simple type (likeString), the code generators incorrectly tried to call methods likeparseString(),writeString(), andupdateString()which don't exist.Root Cause
The generators assumed all associations with
multiplicity="1"were references to model classes and generated calls toparseClassName()orwriteClassName()methods. They didn't account for simple types likeStringwhich are allowed in associations but aren't model classes.Solution
Added a check in all affected generators to determine if the association type is a class in the model using
isClassInModel(). If it's not a model class, the code now uses the primitive field handling logic instead.Rebase on Master
rootvariable was renamed torootElementOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.