java - Using Hibernate, proper connections to DBMS and how make safe query methods -
i created hibernate classes, , several functions access dbms in order take information. typical code each method:
public void f(){ sessionfactory factory = new configuration().configure().buildsessionfactory(); session session=factory.getcurrentsession(); session.begintransaction(); query<allnew> query=session.createquery("select m "+allnew.class.getname()+" m"); list<allnew> list = query.getresultlist(); for(allnew i:list){ .... } session.gettransaction().commit(); system.out.println("done"); }
i believe essential code has problem inside. dbms reaches high number of open connections have reason believe that: when method ends, not inside obj closed.
Comments
Post a Comment