krasa / krasa-jaxb-tools

XJC / JAXB plugin for generation of Bean Validation Annotations (JSR-303) and replacing primitive types
Apache License 2.0
60 stars 49 forks source link

generated @NotNull #4

Closed igler closed 11 years ago

igler commented 11 years ago

A piece of generated Java code looks like this: @XmlElement(required = true) @NotNull @Digits(integer = 5, fraction = 2) protected BigDecimal mask02Mgbeitrag;

Is it possible to suppress the @NotNull generation? It's because JSF complains that the 'mask02Mgbeitrag' is null. But as it is used for a form-based-query, it may be null.

krasa commented 11 years ago

put minOccurs="0" into xsd

igler commented 11 years ago

The problem is that the XSD files are auto-generated out of COBOL copybooks. Cannot influence that. As I have the source code in my workspace I have uncommented the @NotNull generating lines. Fixes the problem for now...

krasa commented 11 years ago

It would be easy to implement an additional parameter:

-XJsr303Annotations:generateNotNullAnnotations=false

same way

-XJsr303Annotations:JSR_349=true

was done

igler commented 11 years ago

Have implemented the corresponding lines in JaxbValidationsPlugins.java. But if I add ':generateNotNullAnnotations=false' to -XJsr303Annotations then no System.out.println(...) are made any more. Same when only adding 'JSR_349=true'. In both cases no @Size etc. are generated any more.

krasa commented 11 years ago

upload it to github.

igler commented 11 years ago

OK, have uploaded it (or so my Eclipse says). Commit is d99b274b7e2f0be0baf19c3dea2ffc6a1dbe900a.

krasa commented 11 years ago

you have to create a fork, and upload it there - and make sure you upload it to some new branch and not master

igler commented 11 years ago

OK, forked, branched and committed the code.

krasa commented 11 years ago

nice, now create a pull request https://help.github.com/articles/creating-a-pull-request

igler commented 11 years ago

OK, done.

krasa commented 11 years ago

Thanks! I will look at it in few hours. Was you able to make it work?

igler commented 11 years ago

No, the System.out.println(...) are not made. Please take a look where the culprit is or where I have forgotten to implement a feature.

krasa commented 11 years ago

well you had it right, I only changed a default value and some minor things... you can look at https://github.com/krasa/krasa-jaxb-tools-example

your changes are now in snapshot repository

krasa commented 11 years ago

by the way, important thing is to run clean, because otherwise nothing will be regenerated.

igler commented 11 years ago

How can I merge this into my fork? Or shall I delete my fork again and use yours?

krasa commented 11 years ago

do not delete it. https://help.github.com/articles/syncing-a-fork

so it would be: git remote add upstream https://github.com/krasa/krasa-jaxb-tools.git git fetch upstream git checkout master git merge upstream/master

igler commented 11 years ago

As I use the Eclipse/Git Plugin and I am new to git: Is everything merged correct now?

krasa commented 11 years ago

it seems so.

igler commented 11 years ago

Shall I delete my branch 'igler' again?

krasa commented 11 years ago

it is up to you

igler commented 11 years ago

ok, deleted it. I can re-branch when I have new suggestions.