Announcement Announcement Module
Collapse
No announcement yet.
Using a Singleton for a DAO class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using a Singleton for a DAO class

    Hi Good day to all ,


    while declaring DAO on to the application-hibernate.xml , is it good to declare the DAO class as a singleton or not ?

    Please tell me the best approach .

    Thanks in advance .

  • #2
    best approach...

    For a bean defined with Singleton scope, the Spring IoC container will create exactly one instance of the object defined by that bean definition. This single instance will be stored in a cache of such singleton beans, and all subsequent requests and references for that named bean will result in the cached object being returned.

    Prototype scope of bean deployment results in the creation of a new bean instance every time a request for that specific bean is made.

    You should use the prototype scope for all beans that are stateful,
    while the singleton scope should be used for stateless beans.

    Comment


    • #3
      Thanks that was helpful.

      Comment

      Working...
      X