开发者

Hibernate Session closings with Hadoop

I'm an intermediate Hibernate user. I am trying to get some traction with Hadoop at my company. I'm using a library called spring-hadoop (https://github.com/SpringSource/spring-hadoop) to configure my application and inj开发者_JAVA技巧ect my dependencies.

I'm having a lot of trouble getting Hadoop to respect my hibernate sessions. I'm hitting the legendary LazyInitializationException.

org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:108) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:150) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150) at p.model.ServicePoint$$EnhancerByCGLIB$$181013ec.getReadResolution() at p.service.ResourceService.getStartDate(ResourceService.java:77)

Resolution is a lazy init field on a ServicePoint object that is retrieved with hibernate in the first part of the map task.

The exception is thrown later on in the map task when I try to work with the ServicePoint object. It is not thrown in the reduce task. Modifying the ServicePoint hibernate mapping is not an option.

I've tried a bunch of approaches suggested by my giant "Java Persistencee with Hibernate" book such as:

  1. Opening a session at the beginning of Map:

Session session = this.sessionFactory.openSession(); session.beginTransaction();

  1. Adding stuff like this to my sessionFactory bean:

prop key="hibernate.connection.release_mode">on_close < /prop>

Before i pull out all stops and try stuff like Conversation Interceptors, can anyone give me a suggestion ? Nothing works and the exception keeps coming.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜