spring - Java- TimerTask-org.hibernate.HibernateException: No Session found for current thread -
my coding having bug @ gettokendao().updatedate(newtok, new date());
line pops out org.hibernate.hibernateexception: no session found current thread
. please me fix problem. here coding
timer t = new timer(); t.scheduleatfixedrate( new timertask() { public void run() { try { gettokendao().updatedate(newtok, new date()); } catch (exception e) { e.printstacktrace(); } system.out.println("5 minutes passed"); } }, 0, // run first occurrence 300000); }
ps: using spring
the scheduler run timertask
in new thread. session/transaction saved in threadlocal variable.
you have open new transaction inside run()
method in timertask
.
Comments
Post a Comment