This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

spring mvc singleton="false DAO issues?  RSS feed

 
selva raja
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!