How can I persist the content of "xsd:any" tag using JAXB and EJB3?

Hello,

Using wsimport I generated a class from the following xsd type:

<xsd:complexType name="MDVendorExtensions_T">

<xsd:sequence>

<xsd:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>

</xsd:sequence>

</xsd:complexType>

The class generated was :

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name ="MDVendorExtensions_T", propOrder ={

"any"

})

publicclass MDVendorExtensionsT{

@XmlAnyElement(lax =true)

protected List any;

public List getAny(){

if (any ==null){

any =new ArrayList();

}

return this.any;

}

}

Then I would have liked to map MDVendorExtensionT into a database using ejb3 annotations. As I can't map a List<Object> I created an entity bean E just to wrap Object. So after adding persitent annotations:

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name ="MDVendorExtensions_T", propOrder ={

"any"

})

@Entity

@Table(name ="MDV")

publicclass MDVendorExtensionsTimplements Serializable{

@Id

private Long id;

@XmlAnyElement(lax =true)

@OneToMany(cascade={CascadeType.ALL})

protected List<E> any;

....

with E containing just an id:

@Entity

publicclass Eimplements Serializable{

@Id

@GeneratedValue(strategy = GenerationType.AUTO)

private Long id;

..

If I have an xml file which contains an element vendorExtension that validate the xsd:any type defined above:

<root>

<vendorExtension>

<element1>first element<element1>

<element2> <element2_1> ....</element2_1></element2>

...

<vendorExtension>

</root>

My question is : how can I store the content of vendorExtension element into the database. There can be as many element as the user want under this element and if I try this code with just

<vendorExtension><element1>first Element <element1></vendorExtension>

I get a

java.lang.IllegalArgumentException: Object: [element1:null] is not a known entity type.

At first I wanted to store the content of vendorExtension as a string (I don't know how to do it either) but I think it's not a good solution if the content is very big

Thank you.

[3744 byte] By [bastrala] at [2007-11-27 9:28:11]
# 1

> > <vendorExtension><element1>first Element

> <element1></vendorExtension>

>

>

> I get a

>

> > java.lang.IllegalArgumentException: Object:

> [element1: null] is not a known entity type.

>

>

Well, before getting into details of the problem what is visible straightaway is that <element1> has not been terminated correctly. It should have been:

<vendorExtension><element1>first Element</element1></vendorExtension>

java_a at 2007-7-12 22:32:13 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Yes just a typo on my post which has nothing to do with my problem.Sorry.
bastrala at 2007-7-12 22:32:14 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...