Results 1 to 3 of 3

Thread: Using a Singleton for a DAO class

  1. #1

    Default 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. #2
    Join Date
    Jun 2008
    Location
    Delhi
    Posts
    2

    Default 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.

  3. #3

    Default

    Thanks that was helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •