Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] How to store a inner bean in XML format

Dear friends,

I would like to store a bean in XML format in a text field in my database.

For example, consider the following custom Map implementation:

class MyBean implements Serializable {
   private String someKey;
   private String someValue;

   ... constructor, getters and setters as usual
}

@XmlRootElement
class MyBeanMap implements Serializable {

  @XmlElement
  private MyBean [] values = new MyBean[20];

  ... all getters and setters as usual
}


Now I would like to have a persistent class

@Entity
class MyWork implements Serializable {
  @Id
  private Id;
  private MyBeanMap myMap = new MyBeanMap();

  ... all getters and setteras as usual
}

How can I make the "myMap" variable be stored as XML Text in the "myMap" column in database? I know I can store it as separate table using @Collections et al, but this time I would like to get it more flexible using XML for compatibility with other tool.

Is there any other way than scanning all object tree and marshalling/unmarshalling it myself?

Thanks,

--
Atenciosamente,

Edson Carlos Ericksson Richter



Back to the top