Re: not again: hibernate OpenSessionInViewInterceptor lazyinitialization
exception
Tom Anderson wrote:
comp.lang.java.programmer wrote:
There are zillions of examples online of persons getting this error
LazyInitializationException happens from attempted access to a
lazily-initializated item after disconnection from entity management. In
other words, as a result of programmer error.
I have been struggling with it now for a few hours and thought I would
share my pain.
I include the configuration and the logging below. I suspect the
session is being closed early and maybe someone might help me figure
out how that's happening. And how to avoid it.
That someone is your debugger. Breakpoint Hibernate's close methods, and
anything likely-looking they call internally, and run your code. You'll see
if, and if so how, the session is being closed.
I also recommend looking at your own code and seeing when you close the
session. Don't underrate the value of code examination and careful thought
thereupon. Knowing where your sessions are is /de rigueur/ in Hibernate
programming. There is no escape from the responsibility.
Also, don't use Hibernate-specific configuration, use the JPA API. The
Hibernate native interface is basically legacy.
+1
Also also, you might have more luck with this on a Spring/Hibernate forum.
There are people here who know Spring and Hibernate on this group, but the
general centre of gravity is closer to EJB, and indeed J2SE.
This forum is fine. I want to know what happens, assuming the OP figures out
how to post to the right thread, which for some reason he absolutely refuses
to do. The subject is on topic and relevant to a plurality of Java practitioners.
OP: Stop breaking the thread. Also, don't use TAB characters in Usenet code
posts. Follow the rules of the road, please. Don't risk a shunning.
--
Lew
Honi soit qui mal y pense.