Announcement Announcement Module
Collapse
No announcement yet.
Need suggestions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need suggestions

    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

  • #2
    Well, I removed all class-wide state from the SQL class... which should make it thread-safe. Guess thats the best solution.

    Comment


    • #3
      All classes derived from a base class should be interchangeable

      Comment

      Working...
      X