java - Multiple simultaneous hibernate sessions per thread -
i'm working on rest webservice uses hibernate or mapper. upgraded hibernate 3.2 4.3 , got error described here. transaction got rolled somewhere , got error when wanted use session again (which correct hibernate behavior).
i think figured out why got error. because when receive request long session started. session opens transaction open longer period of time. besides long running session/transaction small session/transaction should opened on same thread. far found out, sessions same usertransaction
work , since small transactions commit , rollback transaction run in error described in other post.
since i'm working huge code base easy change code side session run in different thread (in case help) or refactor whole service 1 transaction can open @ time.
actual question starts here
is there possibility start multiple simultaneous sessions/transactions in 1 thread? if so, have do, tell hibernate that? if not possible way of accomplishing similar behavior suggest?
code snippet use create sessions
session session = sessionfactory.opensession(); customsessionwrapper dpsession = new customsessionwrapper(session, this); if (!session.isclosed() && !session.gettransaction().isactive()) { session.begintransaction(); }
the code worked before upgraded hibernate problem should not in customsessionwrapper
or other custom class.
thanks lot in advance!
Comments
Post a Comment