I use a org.springframework.http.converter.xml.MarshallingHttpMessageConverter 
with org.springframework.oxm.xstream.XStreamMarshaller as 
marshaller/unmarshaller.
With default-lazy=false hibernate-mapping, 
org.springframework.web.client.RestTemplate.getForObject() works fine.
But with default-lazy = true, some contained objects from the top-level object 
are org.hibernate.proxy.pojo.javassist.SerializableProxy, which makes the 
getForObject() fail, with org.hibernate.LazyInitializationException- could not 
initialize proxy - no Session
Is there a way to get the marshaller to initialize and unproxy as needed, when 
writing to the stream ?
I want to have the same API calls for REST and non-REST situations (non-REST = 
local JVM calls that can make further calls with the Hibernate session, to get 
contents from proxies as needed), and ideally default-lazy = true is preferred 
for non-REST calls, but then if the same call is used by a REST controller, the 
marshalling keeps the proxies as is currently.                                  
     

Reply via email to