Title: Remote Object Persistence Customization
In addition to configuring Extended Types as described in Cayenne Guide, users must pay attention to serialization of the custom property types. A custom class must be serializable so that it can be passed between the client and the server. Cayenne uses a library called Hessian to perform the serialization of objects. Mostly it will just work with custom extended types, but there are some important requirements:
private Object writeReplace() throws ObjectStreamException { // return some object which Hessian will serialize instead of your extended type } private Object readResolve() throws ObjectStreamException { // return the final object in its deserialised form }
Note that the functions are private - that is fine and encouraged since these functions should not normally be available to a subclass.
Instead of all the above you may be able to register an additional SerializerFactory to handle your extended type by using com.caucho.hessian.io.SerializerFactory.addFactory((AbstractSerializerFactory factory). This will give you complete control over the process.