0

I have a problem with generating classes using xjc. In the schema I have nillable="false", yet this is not added as an annotation (@XmlElement(nillable=false)) on the generated fields. This causes Jackson not to remove the fields when they are empty. If I change to nillable=true, the classes are updated to reflect that as expected...

Any ideas?

Erlend
  • 4,215
  • 20
  • 25
  • 1
    `nillable` is false by default (i.e. `@XmlElement(nillable=false)` and `@XmlElement()` are identical). – Ian Roberts Aug 28 '12 at 13:11
  • 1
    Jackson is not a JAXB (JSR-222) compliant implementation. There are no guarantees how it will interpret any standard JAXB annotation. – bdoughan Aug 28 '12 at 13:22
  • I guess that's what I'm facing. If I manually add XmlElement(nillable=false) to the generated source files, then Jackson works as expected... So for Jackson @XmlElement(nillable=false) is not the same as @XmlElement() – Erlend Aug 28 '12 at 20:21

1 Answers1

0

So I ended up writing my own plugin for maven-jaxb2-plugin which checks the attributes and adds missing @XmlElement(nillable = false).

Erlend
  • 4,215
  • 20
  • 25