So here is my situation: I have a web-app with several controllers. Each controller is injected with a singleton bean which is used as the API to backend functionality. This bean will be injected with several singleton DAO beans to perform various queries and return data objects. As it stands now, each DAO has a unique class variable object and this object will contain only SQL statements. Data is passed down from the request->controllers->interfacing bean->DAO->SQL object. The query string is constructed/completed with the parameters and returned to the DAO to perform the query and construct the data object. Since the SQL class of the DAO is a class variable, it is not thread-safe. I need some help making it thread-safe. Should I synchronize the SQL methods that construct and return the SQL statements? Perhaps this is the worst option since it could possibly degrade performance. What are some better techniques for the above scenario?
Thanks


Reply With Quote