java - LazyInitializationException when using threads -


i keep getting error when trying fetch objects database:

org.hibernate.lazyinitializationexception (lazyinitializationexception.java:19)     - not initialize proxy - no session 

but error when using threads. our application structure method call flow as:

facadeimpl.saverv() -->  @transactional @parallelcontext businessimpl.validateentry() -->  businessimpl.getopmap() -->  @paralleltask daoimpl.getmefilter() 

i lazyinitializationexception when trying access field of fetched entities, defined as:

// bi-directional many-to-one association ptoconex @manytoone(fetch = fetchtype.lazy) @joincolumn(name = "idn_pto_conex", insertable = false, updatable = false) private ptoconex progtptoconex; 

however, if remove @parallelcontext annotation declaration of businessimpl.validateentry() , @paralleltask daoimpl.getmefilter(), don't have problem.

the hibernate session , entities loaded session not thread safe. if try accessing them different thread run kind of "weird" exceptions.

most of time mixing transactions concurrency bad idea.


Comments