How can i avoid this issue , for the below line
Query query = getSession().createQuery("my sql query");
or
Session session = getSession();
SQLQuery query = session.createSQLQuery("");
There are a couple of queries in my DAO implementation and I cannot close the session after every query execution(If I do will not create connection pool bottleneck or overuse of memory?).
But I need to fix this issue or provide an appropriate reason to make this a positive error.
Please guide
There are a few options:
finally
block. This would execute only if an exception occurs. I don't think creating a custom rule would work here since there is no taint or session closing function to instrument.