Announcement Announcement Module
Collapse
No announcement yet.
When is a singleton not a singleton? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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="com.acs.gs.juror.dao.impl.BioAnswersDAOImpl ">
    <property name="dataSource" ref="jurorDatabase"/>
    <property name="bioQuestionnaire" ref="bioQuestionnaire"/>
    <property name="jurorQuestionnaire" ref="jurorQuestionnaire"/>
    </bean>

    <bean id="participantDao" class="com.acs.gs.juror.dao.impl.ParticipantDAOImp l">
    <property name="sessionFactory" ref="jurorSessionFactory"/>
    <property name="bioAnswers" ref="bioAnswersDao"/>
    </bean>

  • #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:

    http://forum.springframework.org/showthread.php?t=30410

    Ben

    Comment

    Working...
    X