users@jaxb.java.net

wrapping collections by using adapters

From: Dmitri Colebatch <dim_at_colebatch.com>
Date: Fri, 17 Mar 2006 18:40:36 +1100

Hi all,

I have a problem trying to map a collection. I've had this for a
while and have been putting it aside but am hoping that someone might
be able to point out something obvious. I'll attach some runnable
code, but will paste some of it here for clarity.

I have an object Foo, that has a set of Bar instances. I want this to
map to the following xml:

<foo>
  <bars>
    <bar>
      <name>abc</name>
      <price>123</price>
    </bar>
  </bars>
</foo>

I've tried doing this by having a "BarWrapper" class that I inject
using an adapter, however this isn't working (CCE on marshall). I've
tried various other workarounds as well, but none of them seem to get
me to where I want. It seems like a simple problem, I feel like I
must be missing something obvious. Any suggestions?

The reason I don't just change the xml structure is that I am also
mapping this class with hibernate annotaions, and I don't see a way to
remove the middle man (BarWrapper) when doing a one-to-many.

cheers
dim

(code attached)