How to Persist a Map of beans to collections of beans?

#1

Hello,

I am trying to add a new persistable object to the package.jdo for persistence in a .odb file.  The class contains a field that is as follows:

private Map<SomeKindaBean, List<SomeOtherTypeOfBean>> m_objectToPersist;

I'm at a loss for how to format the xml in the .jdo file for this object.  How does one persist this in package.jdo xml?  Thanks in advance for your help.

-A

#2

In the package.jdo file you only have to list the persistence capable classes. No need to specify fields unless you want to configure them differently than the default.

But both SomeKindaBean and SomeOtherTypeOfBean must be persistent types (i.e. if they are user defined classes they have to be specified as persistence capable classes).

Support of map values which are collections is non standard and may be limited, so if this doesn't work consider wrapping List<SomeOtherTypeOfBean> in a new persistence capable class (e.g. SomeOtherTypeOfBeanList, and use Map<SomeKindaBean, SomeOtherTypeOfBeanList>).

ObjectDB Support

Reply