I use hibernate to manage my database/javaWebApplication interaction, with new requirements i had to have scrollable results and map my own query results, i made this generic class in java to return scrollableResults
public ScrollableResults executeCursorQuery(final String
queryString, final Object... params) throws PersistenceException
{
Session session = SessionFactoryUtil.getSessionFactory().openSession();
SQLQuery sqlQuery = session.createSQLQuery(queryString);
int position = 0;
for (Object param: params) {
sqlQuery.setParameter(position, param);
position++;
}
ScrollableResults results = sqlQuery.scroll();
return results;
}
i iterate over the result and map my info perfectly and after i'm done i do
SessionFactoryUtil.getSessionFactory().getCurrentSession().close();
it works fairly good but after a few calls to this method it crashes the app, i imagine it is because of the sessions being open every time because i also use c3p0 to handle connection pool. I really don't know i'm on a loop here if anyone spots the error or knows what i'm doing wrong and can point me in the right directions it will be greatly appreciated.