Mantis - Hessian
Viewing Issue Advanced Details
2796 minor always 07-18-08 08:55 07-28-08 04:47
0002796: Hessian customization
(rep by Harald Radi)

i want to implement a custom serializer that overrules hessians default serialization implementation based on some custom annotations. I have the following usecase: I want to send JPA entities over the wire, but I don?t want the serializer to traverse all @ManyToOne mapped properties (and hence trigger a sql select) ? instead it should just serialize the id of those (the foreign key) which are available even without a further select. For that I annotated such fields with @SerializeById.
Now, trying to make the hessian serialization mechanism aware of this my naive approach would have been:
- add a custom SerializerFactory that provides a serializer for such annotated entities
- derive from JavaSerializer and overwrite getFieldSerializer and provide a different implementation for annotated fields
There are two difficulties with that approach:
- getFieldSerializer is private static, it needs to be protected for that
- only ?field.getType()? is passed to getFieldSerializer, to be able to access annotations the ?field? needs to be passed to it
This requires me to maintain a copy of the JavaSerializer class on my own, do you think that this is something that could be changed for the next release? The same applies to the deserializer of course. [^] (9,835 bytes) 07-28-08 04:43 [^] (18,069 bytes) 07-28-08 04:44

07-28-08 04:47   
I attached the two files including the necessary modifications, sorry for not providing a diff.