This is a general question, not specific to my current application.
In a heavy Traffic MultiThreaded application, what is the approach to do following: assume that there is a DAO which contains a method updateData to update some data inside of a database.
Questions:
- Is it a good approach to have a Singleton instance of that DAO class and access it’s method
updateData? - Or should I every time create a new object of that DAO and call the method
updateData?
Yes it is definitely good idea to create a singleton for such services, make sure it doesn’t have any state related issue when accessed by multiple threads
I would have marked such DAOs as Spring beans