Servlet code:
Code:
doGet(...) {
List results = DataLoader.getResultSet();
}
Extra classCode:
public class DataLoader {
...
public static final List getResultSet() throws HibernateException {
ConnectionHandler handler = (ConnectionHandler) connections.get(connectionName);
Session session = handler.getOrCreateSession();
Criteria criteria = session.createCriteria(...);
....
return criteria.list();
}
}
1) Is the above code thread-safe?
2) If yes, then is it ok if I put all queries used by my application in DataLoader's
static methods and will be executing them from all servlets?