Home » Tag Archives: JAXB (page 2)

Tag Archives: JAXB

Orika: Mapping JAXB Objects to Business/Domain Objects

java-interview-questions-answers

This post looks at mapping JAXB objects to business domain objects with Orika. Earlier this month, I covered the same mapping use case using reflection-based Dozer. In this post, I’ll assume the same example classes need to be mapped, but they will be mapped using Orika instead of Dozer. Dozer and Orika are intended to solve the same type of ...

Read More »

Dozer: Mapping JAXB Objects to Business/Domain Objects

java-interview-questions-answers

Dozer is an open source (Apache 2 license) "Java Bean to Java Bean mapper that recursively copies data from one object to another." As this description from its main web page states, it is used to map two JavaBeans instances for automatic data copying between the instances. Although these can be any of the many types of JavaBeans instances, I ...

Read More »

Mockito – RETURNS_DEEP_STUBS for JAXB

mockito-logo

Sorry for not having written for some time but I was busy with writing the JBoss Drools Refcard for DZone and I am in the middle of writing a book about Mockito so I don’t have too much time left for blogging… Anyway quite recently on my current project I had an interesting situation regarding unit testing with Mockito and ...

Read More »

MOXy’s Object Graphs & Dynamic JAXB

java-interview-questions-answers

JAXB (JSR-222) makes it easy for you to convert instances of your domain classes to/from XML.  The EclipseLink MOXy implementation offers an extension called Dynamic JAXB where instead of real classes you have instances of a map like class called DynamicEntity. You can access the data on your DynamicEntity using get and set methods that take the property name (i.e. ...

Read More »

Binding to JSON & XML – Handling Collections

eclipselink-logo

One of EclipseLink JAXB (MOXy)‘s strengths is the ability to map an object model to both JSON and XML with a single set of metadata. The one weakness had been that you needed to compromise on the JSON key or XML element for collection properties. I’m happy to say that this issue has been solved in EclipseLink 2.5 (and EclipseLink ...

Read More »

JAXB and java.util.Map

java-interview-questions-answers

Is it ironic that it can be difficult to map the java.util.Map class in JAXB (JSR-222)? In this post I will cover some items that will make it much easier. Java Model Below is the Java model that we will use for this example. Customer The Customer class has a property of type Map . I chose this Map specifically ...

Read More »

JAXB tutorial – Getting Started

java-interview-questions-answers

Note: Check out our JAXB Tutorial for Java XML Binding – The ULTIMATE Guide What is JAXB? JAXB stands for Java architecture for XML binding.It is used to convert XML to java object and java object to XML.JAXB defines an API for reading and writing Java objects to and from XML documents.Unlike SAX and DOM,we don’t need to be aware ...

Read More »

JAXB – Representing Null and Empty Collections

java-interview-questions-answers

Demo Code The following demo code will be used for all the different versions of the Java model. It simply sets one collection to null, the second to an empty list, and the third to a populated list.             package package blog.xmlelementwrapper; import java.util.ArrayList; import javax.xml.bind.*; public class Demo { public static void main(String[] args) ...

Read More »

Applying a Namespace During JAXB Unmarshal

java-logo

For some an XML schema is a strict set of rules for how the XML document must be structured. But for others it is a general guideline to indicate what the XML should look like. This means that sometimes people want to accept input that doesn’t conform to the XML schema for some reason. In this example I will demonstrate ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.