Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330402 - @XmlNullPolicy, Collections, and Empty Nodes
Summary: @XmlNullPolicy, Collections, and Empty Nodes
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 331151
  Show dependency tree
 
Reported: 2010-11-16 15:24 EST by Blaise Doughan CLA
Modified: 2022-06-09 10:28 EDT (History)
1 user (show)

See Also:


Attachments
Core - Fix (15.36 KB, patch)
2010-11-16 15:28 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (4.98 KB, patch)
2010-11-16 16:34 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (5.45 KB, patch)
2010-11-25 14:28 EST, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (16.58 KB, patch)
2010-11-25 14:29 EST, Blaise Doughan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2010-11-16 15:24:06 EST
For the following class:

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import org.eclipse.persistence.oxm.annotations.XmlMarshalNullRepresentation;
import org.eclipse.persistence.oxm.annotations.XmlNullPolicy;

@XmlRootElement
public class Course {

    @XmlElement (name = "book")
    @XmlNullPolicy(nullRepresentationForXml = XmlMarshalNullRepresentation.EMPTY_NODE, emptyNodeRepresentsNull=true)
    List<Book> requiredBooks = new ArrayList<Book>();

}


The XML document:

<?xml version="1.0" encoding="UTF-8"?>
<course>
    <book/>
    <book>
        <title>Hello World</title>
    </book>
    <book/>
</course>

Should unmarshal to an object where the requiredBooks property contains two nulls and an instance of Book.  Currently this is not working.
Comment 1 Blaise Doughan CLA 2010-11-16 15:28:25 EST
Created attachment 183266 [details]
Core - Fix
Comment 2 Blaise Doughan CLA 2010-11-16 16:34:19 EST
Created attachment 183268 [details]
MOXy - Test Cases
Comment 3 Blaise Doughan CLA 2010-11-25 14:28:58 EST
Created attachment 183879 [details]
MOXy - Test Cases
Comment 4 Blaise Doughan CLA 2010-11-25 14:29:17 EST
Created attachment 183880 [details]
Core - Fix
Comment 5 Blaise Doughan CLA 2010-11-25 16:48:13 EST
Fix checked into trunk at rev:  8569

Code reviewed by:  Matt MacIvor

- Added CompositeCollectionMappingContentHandler
- Refactored CompositeObjectMappingContentHandler to have a super type that CompositeCollectionMappingContentHandler could leverage to share behaviour.
- Added similar support to CompositeCollectionMapping from CompositeObjectMapping to handle empty element null values.
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:28:48 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink