Announcement Announcement Module
No announcement yet.
When is a singleton not a singleton? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • When is a singleton not a singleton?

    I have a singleton DAO with some state that is constructed in a spring XML file as a singleton. It is then passed into another DAO which is also a singleton. The state of this DAO should be the same for the lifetime of the JVM, correct?

    Why is it then that state that is created the first time it is called is not there when I return to it later in the application? Isn't that impossible?

    Any ideas as to what I can look at?

    Here's the def of the first DAO and where it's used:

    <!-- Define each data access object -->
    <bean id="bioAnswersDao" class=" ">
    <property name="dataSource" ref="jurorDatabase"/>
    <property name="bioQuestionnaire" ref="bioQuestionnaire"/>
    <property name="jurorQuestionnaire" ref="jurorQuestionnaire"/>

    <bean id="participantDao" class=" l">
    <property name="sessionFactory" ref="jurorSessionFactory"/>
    <property name="bioAnswers" ref="bioAnswersDao"/>

  • #2
    Spring "singletons" are not JVM singletons. This as apparently caused much confusion because of the JVM connotation to that word. I wish they'd picked a different name. See here for explanation: