You can use any Java XML serialization library, e.g. XStream. It is already in the dependencies of the core module, so you can do the conversion in a middleware service.
But why do you want to save the serialized entity and not just its ID?
I resolved this problem myself. I need this because I have no persistent entity which I show in edit window before any proces. I need to save values form this editwindow. Now I convert entity to xml
and use userSettingService when I accept editwindow, When I need show this window again I read saving values from userSettingService,covert xml to entity and show in editwindow.
I attach exemplary class. Class ParamsWidow manages to show editwindow and load values from userSettingService. Entity class have to have xml annotations e.g. @XmlAttribute(name = “currdate”)