Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 368547

Summary: Enhancement: Provide a means to default the nillable setting for all @XmlElement
Product: z_Archived Reporter: Blaise Doughan <blaise.doughan>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: snsekar, tomas.kraus, voytoo
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
URL: http://stackoverflow.com/questions/8841221/can-you-change-the-default-value-of-the-nillable-attribute-in-jaxb
Whiteboard:
Attachments:
Description Flags
Patch fix for this bug.
none
same patch rebased against master with CRLF fix
tomas.kraus: review+
javadocs
tomas.kraus: review+
rebased against new master
none
fixed CRLF voytoo: review?, tomas.kraus: review+

Description Blaise Doughan CLA 2012-01-13 09:28:23 EST
The default value for nillable on the @XmlElement annotation is false.  If you wanted to make all the fields/properties mapped to XML elements nillable you would need to annotate every one.  To make this easier we could provide an extension to set a package level default.
Comment 1 Martin Vojtek CLA 2014-07-03 05:30:52 EDT
I am working on the enhancement.
Comment 2 Martin Vojtek CLA 2014-07-24 08:11:00 EDT
Created attachment 245337 [details]
Patch fix for this bug.

Introduced new annotation XmlElementNillable with ElementType.TYPE and ElementType.PACKAGE targets. Annotation with ElementType.TYPE overrides annotation with ElementType.PACKAGE.

I have also extended annotation XmlNullPolicy to target ElementType.TYPE and ElementType.PACKAGE. I think it makes sense and its purpose and behavior is different than XmlElementNillable annotation. Purpose of XmlElementNillable is to extend standard XmlElement annotation with targets ElementType.TYPE and ElementType.PACKAGE.

New xsd schema eclipselink_oxm_2.6.xsd introduced, which contains new xml elements xml-element-nillable and xml-null-policy.
Comment 3 Martin Vojtek CLA 2014-07-24 08:12:09 EDT
Created attachment 245338 [details]
same patch rebased against master with CRLF fix

This is the same patch as before, but it is created against current master. It also fixes CRLF issues. But is much bigger.
Comment 4 Tomas Kraus CLA 2014-07-24 10:33:41 EDT
testBeanValidation	Error	Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.

javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:271)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
at org.eclipse.persistence.testing.jaxb.beanvalidation.BeanValidationRuntimeTestCase.setUp(BeanValidationRuntimeTestCase.java:215)

Nevim jestli je to nejaky starsi problem, ale tehle test mi neprosel.
Comment 5 Tomas Kraus CLA 2014-07-24 10:34:55 EDT
Oops,

'Nevim jestli je to nejaky starsi problem, ale tehle test mi neprosel.' ->
'I'm not sure if this is some older issue but this test did not passed.'
Comment 6 Martin Vojtek CLA 2014-07-24 15:28:43 EDT
Created attachment 245348 [details]
javadocs

Added javadocs for XmlElementNillable annotation and for corresponding tests.
Comment 7 Martin Vojtek CLA 2014-07-25 07:43:58 EDT
Created attachment 245382 [details]
rebased against new master

rebased against new master
Comment 8 Martin Vojtek CLA 2014-07-25 08:43:44 EDT
Created attachment 245384 [details]
fixed CRLF

fixed CRLF
Comment 10 Eclipse Webmaster CLA 2022-06-09 10:15:02 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 11 Eclipse Webmaster CLA 2022-06-09 10:27:53 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink