Scott Ferguson wrote (2007-11-05 17:09):
On Nov 2, 2007, at 5:14 AM, Mattias Jiderhamn wrote:
... among other things I want to transfer over the service are collections from/in Hibernate objects. That is, the collections are
instances of Hibernates PersistentMap, PersistentList, PersistentSet etc. This will cause trouble, since the receiving end will think the
collection is not yet initialized, but it is also not bound to a session and thus an exception will be throws (for search enginge indexing, I'm
talking about the LazyInitializationException , "failed to lazily initialize a collection, no session or session was closed").
In my current case, I can easily wrap the PersistentMap in a HashMap to avoid the issue, but then (apart from the tiny performance loss)
suddenly it is not as beatifully transparent anymore. I'm thinking there must be a way to tell Hessian to serialize the PersistentMap as a
Map of unknown kind (which will be deserialized as a HashMap) using a custom serializer. There seems to be a way to set the SerializerFactory of
the HessianServlet and/or addFactory() to the SerializerFactory. What would be the most correct way of doing this?
There's a setSendCollectionType(boolean) in the SerializerFactory and
HessianServlet. If you set it to false, it will serialize the
collection as a raw list.
As far as I can tell from looking at the code, there is no such thing
for Maps, which is what I need right now.
That is, I would need a
com.caucho.hessian.io.MapSerializer.setSendJavaType().
I have added this here: http://bugs.caucho.com/view.php?id=2149
It does look like you'd need to extend HessianServlet to set it, though.
Mentioned that in the report above too.
/Mattias
|
_______________________________________________
hessian-interest mailing list
hessian-interest-p4ZHcaHNc0TQT0dZR+AlfA@xxxxxxxxxxxxxxxx
http://maillist.caucho.com/mailman/listinfo/hessian-interest
|
|