GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix multiplicity=1 for simple type associations in Reader/Writer generators by Copilot · Pull Request #521 · codehaus-plexus/modello

Conversation

Copilot AI commented Oct 6, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixing issue with multiplicity=1 for simple type associations in Reader/Writer generators

  • Understand the issue: when an association has multiplicity=1 and type is a simple type like String, generators incorrectly call parseString/writeString/updateString methods that don't exist
  • Create test case to reproduce the issue
  • Fix Xpp3ReaderGenerator to handle simple type associations with multiplicity=1
  • Fix Xpp3WriterGenerator to handle simple type associations with multiplicity=1
  • Fix SnakeYamlReaderGenerator to handle simple type associations with multiplicity=1
  • Fix SnakeYamlWriterGenerator to handle simple type associations with multiplicity=1
  • Fix StaxReaderGenerator to handle simple type associations with multiplicity=1
  • Fix StaxWriterGenerator to handle simple type associations with multiplicity=1
  • Fix JDOMWriterGenerator to handle simple type associations with multiplicity=1
  • Verify all tests pass
  • Rebased on master and resolved conflicts with Root -> rootElement rename

Summary

The issue was that when an association field has multiplicity="1" and the type is a simple type (like String), the code generators incorrectly tried to call methods like parseString(), writeString(), and updateString() which don't exist.

Root Cause

The generators assumed all associations with multiplicity="1" were references to model classes and generated calls to parseClassName() or writeClassName() methods. They didn't account for simple types like String which 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

  • Successfully rebased on latest master (commit bca1253)
  • Resolved conflict in JDOMWriterGenerator.java where root variable was renamed to rootElement
  • All tests pass after rebase
Original prompt

This section details on the original issue you should resolve

<issue_title>multiplicity with 1 for simple type generate wrong code in Reader/Writer</issue_title>
<issue_description>Eg for field type of String we have used method like:

  • parseString
  • writeString
  • updateString

which is not defined

to reproduce use:

        <field>
          <name>listField</name>
          <type>List</type>
          <association>
            <type>String</type>
            <multiplicity>1</multiplicity>
          </association>
        </field>
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>
Fixes #403

💡 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI assigned Copilot and slachiewicz Oct 6, 2025
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
Copilot AI requested a review from slachiewicz October 6, 2025 22:39
@slachiewicz
slachiewicz marked this pull request as ready for review October 6, 2025 22:49
@slachiewicz

slachiewicz commented Oct 8, 2025

Copy link
Copy Markdown
Member

@copilot please rebase on master, fix conflicts and adjust code if needed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI commented Oct 8, 2025

Copy link
Copy Markdown
Contributor Author

@copilot please rebase on master, fix conflicts and adjust code if needed

Rebased on master successfully. The conflict in JDOMWriterGenerator.java was resolved by updating references from root to rootElement to match the recent fix for Root class name conflicts. All tests pass. Commit: 83eaa22

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gnodet
gnodet approved these changes Oct 8, 2025
View reviewed changes
slachiewicz
slachiewicz approved these changes Oct 8, 2025
View reviewed changes
Copilot AI and others added 3 commits October 8, 2025 23:22
@slachiewicz
Add test case to reproduce multiplicity=1 simple type association issue
5e2e0d7
Co-authored-by: slachiewicz <[email protected]>
@slachiewicz
Fix Xpp3 reader and writer for simple type associations with multipli…
5479f2c
…city=1

Co-authored-by: slachiewicz <[email protected]>
@slachiewicz
Fix SnakeYaml, Stax, and JDOM generators for simple type associations…
3a12096
… with multiplicity=1

Co-authored-by: slachiewicz <[email protected]>
@slachiewicz
slachiewicz force-pushed the copilot/fix-dc3f927a-7502-4bc2-8a59-22d65369efed branch from 70d6dc1 to 3a12096 Compare October 8, 2025 21:26
@slachiewicz
slachiewicz merged commit 57c2923 into master Oct 8, 2025
@slachiewicz
slachiewicz deleted the copilot/fix-dc3f927a-7502-4bc2-8a59-22d65369efed branch October 8, 2025 21:36
@slachiewicz slachiewicz added the enhancement New feature or request label Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gnodet gnodet gnodet approved these changes
+1 more reviewer
@slachiewicz slachiewicz slachiewicz approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@slachiewicz slachiewicz

Copilot code review Copilot

Labels

enhancement New feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

multiplicity with 1 for simple type generate wrong code in Reader/Writer

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@slachiewicz @gnodet
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.