aspose file tools*
The moose likes Spring and the fly likes spring mvc singleton= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "spring mvc singleton="false DAO issues?" Watch "spring mvc singleton="false DAO issues?" New topic
Author

spring mvc singleton="false DAO issues?

selva raja
Ranch Hand

Joined: Nov 24, 2009
Posts: 69
Dear all,

In spring mvc in my all dao implantation classes set scope is singleton="false". Is it correct approach or not? If it is correct ...When we need to set to all daos are set to singleton="true"?



Please clarify the same.

Thanks,
SR
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

selva raja wrote:Dear all,

In spring mvc in my all dao implantation classes set scope is singleton="false". Is it correct approach or not? If it is correct ...When we need to set to all daos are set to singleton="true"?



Please clarify the same.

Thanks,
SR


Well singleton="true" is a Spring 1.x xml configuration. In Spring 2.x and above there is a scope="" to change the scope from Singleton to any other scope. But as far as DAO/Repositories, they shouldn't be holding any state, therefore being a stateless object and best as a Singleton, since you only need one instance to handle all your users. Many threads can call the same method at the same time in a single instance without any issues. It is only when you hold state that you have to think of Threading issues.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spring mvc singleton="false DAO issues?