Proper Mapping Annotations: A Step in the right direction?


Quick recap

Last Friday…10 minutes till quitting time, I come across some info on “Mapping Annotation”. I’ve been using the @XMLElement annotation for most of my bean properties, and sometimes they work…but not in this one particular bean. (yes, I’d been taking the Java to XML approach) First, you have to understand how I was using this annotation. My bean code looked like this:

Bean Code (Fig 1.1)

Now, at some point, it seemed necessary to use a wrapper class so that I could return an Array of these beans. So a built this little guy:

Bean Array Wrapper (fig 1.2)
Although this strategy was successful in another case, it failed at deserialization in the web service client application. Here’s a little bit of …

NEWS BREAK…I INTERRUPT THIS BLOG TO BRING YOU THIS IMPORTANT AND PERHAPS MEANINGLESS INFORMATION

ARRRRGG!!! In an attempt to reconstruct this crime scene, my old code worked! This is very frustrating. I was going to give you this cool little post about how I solved my little problem by adding the “name” attribute to the @XMLElement annotation, but when I removed the name attribute, redeployed to Glassfish, regenerated/recompiled/redeployed my client…it $@$%ING WORKED!

Despite this confusion, I believe I will continue annotating my bean properties like this:

@XMLElement with name property for better mapping (fig. 1.3)

…because it got things working.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s