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

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -