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

Substitue getters and setters are Lowercase #3

Closed
bghost4 opened this issue Sep 29, 2021 · 6 comments
Closed

Substitue getters and setters are Lowercase #3

bghost4 opened this issue Sep 29, 2021 · 6 comments

Comments

@bghost4
Copy link

bghost4 commented Sep 29, 2021

for example if your class has a substitued field called feature the getter and setter for the field is getfeature and setfeature, instead of getFeature/setFeature

@bertramn
Copy link
Collaborator

bertramn commented Sep 30, 2021

Are you able to create a simple test case for this scenario? I vaguely remember that I only transfer the element info throughout the post processing so whatever XJC spits out as bean property name would be driven by whatever is configured in your binding context. I have never seen the plugin lowercase anything and we used this plugin to generated tones of bindings.

@bghost4
Copy link
Author

bghost4 commented Sep 30, 2021

I seemingly fixed the issue: I created a pull request.

@bghost4
Copy link
Author

bghost4 commented Sep 30, 2021

here is the example of what I am doing and getting: https://github.com/bghost4/jaxb-substitution-example
this also shows Issue #2 as well. using plugin v0.0.6

@bghost4
Copy link
Author

bghost4 commented Oct 15, 2021

bump. Am I doing something wrong to cause this behavior?

@bertramn
Copy link
Collaborator

bertramn commented Oct 19, 2021

The reason your generated code does not run is because ALL extended classes (from substitution group) need to also be annotated with @XmlRootElement. I should really add this to the plugin functionality. When I wrote this stuff we actually did XML to JSON binding which required a stack of Jackson annotations on these models. So we just used jxb bindings and the jaxb2-annotate-plugin to add the required annotations in one wash. It looked something like this:

<jaxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:annox="http://annox.dev.java.net"
               xmlns:substitution="http://jaxb2-commons.dev.java.net/basic/substitution"
               jaxb:extensionBindingPrefixes="annox substitution"
               jaxb:version="2.1">

    <jaxb:bindings node="xsd:complexType[@name='CarType']">
      <annox:annotate target="class">@javax.xml.bind.annotation.XmlRootElement(name="Car")</annox:annotate>
    </jaxb:bindings>

</jaxb:bindings>

Not sure exactly where that all goes in the gradle ecosystem (we use maven) but hope this helps.

Tip: target the xsd types in the jaxb binding customisations as they are the ones that are used for class generation. If you try to target elements the XJC will fall over with some cryptic error.

@bghost4
Copy link
Author

bghost4 commented Oct 19, 2021

Thanks very much for the update

bertramn added a commit that referenced this issue Dec 5, 2023
* update project dependencies
* bug fix #3 wrongly setting public element name to lower case
bertramn added a commit that referenced this issue Dec 5, 2023
* update project dependencies
* bug fix #3 wrongly setting public element name to lower case
bertramn added a commit that referenced this issue Dec 5, 2023
* update project dependencies
* bug fix #3 wrongly setting public element name to lower case
bertramn added a commit that referenced this issue Dec 5, 2023
* update project dependencies
* bug fix #3 wrongly setting public element name to lower case
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

No branches or pull requests

2 participants