I have annotated a relation as follow
Code:
@ManyToMany(fetch = FetchType.EAGER)
@MapKeyColumn(name = "E_TPSISDK_K_ORDINAMENTO")
@JoinTable(name = "V_DCM_TYPE_CLASS", joinColumns = {
@JoinColumn(name = "K_DOCUMENTO_AZIENDALE", referencedColumnName = "K_DOCUMENTO_AZIENDALE"),
@JoinColumn(name = "K_SOTTO_APPLICAZIONE", referencedColumnName = "K_SOTTO_APPLICAZIONE") }, inverseJoinColumns = {
@JoinColumn(name = "K_CLASSE_DOCUMENTALE", referencedColumnName = "K_CLASSE_DOCUMENTALE"),
@JoinColumn(name = "N_FOLDER_DOCUMENTO", referencedColumnName = "N_FOLDER_DOCUMENTO") })
private Map<SystemId, DocumentClass> docClassMap = new HashMap<SystemId, DocumentClass>();
When I use Hessian to Serialize the Entity which contains this relation, I always have:
Caused by: com.caucho.hessian.io.HessianFieldException: it.nacon.gedi.typeregistry.domain.DocumentType.docClassMap: java.util.Map cannot be assigned from null
at com.caucho.hessian.io.JavaDeserializer.logDeserializeError(JavaDeserializer.java:677) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java:400) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:233) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:157) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.io.SerializerFactory.readObject(SerializerFactory.java:378) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2051) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1977) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1969) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:78) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1700) ~[hessian-3.2.0.jar:na]
at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:220) ~[hessian-3.2.0.jar:na]
at $Proxy71.getTypes(Unknown Source) ~[na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_21]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_21]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_21]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_21]
at org.springframework.remoting.caucho.HessianClientInterceptor.invoke(HessianClientInterceptor.java:222) ~[spring-web-3.0.4.RELEASE.jar:3.0.4.RELEASE]
... 61 common frames omitted
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed
Why Hibernate try a lazy inizialization of this collection?