我有几个REST Web服务,我正在使用CXF Servlet公开。但是我遇到了一个类需要一个懒惰加载的集合(多个列表)的问题。我明白了:
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: my.Model.lists, could not initialize proxy - no Session
我的cxf配置非常简单:
<jaxrs:server address="/v2" id="connectionService">
<jaxrs:serviceBeans>
<ref bean="testService" />
<ref bean="modelServicesLogic" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="myLoggingFilter"/>
<ref bean="jacksonProvider"/>
<ref bean="myExceptionHandler" />
</jaxrs:providers>
</jaxrs:server>
如何实现“在视图中打开会话”模式,以便在Jackson序列化对象时我的hibernate会话可用?