Dear Friends,
The problem is pertaining to the Lazy loading issues that we face when we use Remoting + Hibernate3 + Spring + .NET / Swing clients.
I have searched endless blogs / mailing lists and tried ALL possible options to make this combination work, before posting this email to you.
Problem:
-----------------------------------------------------------
Hibernate:
We have around 55 beans most of them related to each other via OneToMany and ManyToMany relationships, some being Lazy and some Eager. Collection types vary from ArrayList / HashMap and HashSet. This is a quite a complex maze of relationships that we have drawn. I have avoided getters / setters as advised by Java Beans and all our properties are public defined.
Remoting:
We have loaded the servlet using latest versions of Hessian / Burlap and HTTP Invoker. We would prefer to use Hessian because we are also connecting to our service via .NET clients. The servlet loads all 3 remoting methods and I try to connect via each of the transports individually from the client.
NOTE: I am using the latest version of Hibernate3 whose List / Map / Set definitions have changed since the earlier versions of Hibernate2. Most of the solutions provided pertained to Hibernate2 with simple class structures.
Solutions tried for the problem:
-----------------------------------------------------------
We have a maze of relationships and many such objects loading, I have tried the following options and NONE of them worked in any of the remoting methods:
1) I am trying various options to detach loaded Objects from Hibernate Cache, which I think would then make it easier to transmit data using any of the remoting methods.
* Do a Session.clear() so that all the loaded hibernate objects in the current session get detached!
* Recuersively traverse the Hibernate Tree and do a evict of all the objects, so that the objects get detached from the cache
2) Another option was to build a custom serializer for Hessian which will convert the Hibernate Collections to Java Collections.
* CustomSerializerFactory for Hessian that overrode ListSerializer / MapSerializer / SetSerializer for Hibernate3 (and not List / Map / Set interfaces of Hibernate2)
When using HTTPInvoker I get
Quote:
nested exception is java.io.StreamCorruptedException: invalid type code: AC
Caused by: java.io.StreamCorruptedException: invalid type code: AC
at java.io.ObjectInputStream.readObject0(Unknown Source)
When using Hessian / Burlap I get
Quote:
SEVERE: failed to lazily initialize a collection, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollect ion.throwLazyInitializationException(AbstractPersi stentCollection.java:358)
When using Hessian with Custom Serializer I get
Quote:
Caused by: com.caucho.hessian.io.HessianProtocolException: expected end of map ('z') at '?'
at com.caucho.hessian.io.HessianInput.error(HessianIn put.java:1647)
at com.caucho.hessian.io.HessianInput.readMapEnd(Hess ianInput.java:1225)
Can someone help / guide / advise me please.
Thanks in advance,
Rahul