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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -