I am currently working on the Quizzing Tool, which uses hibernate and spring. I actually build it as a Sakai LMS tool, and this complicates this question a bit more, but let me see if I can generalize.
My current scenario is when users go to the StartQuiz page, which, when the form is submitted on the page, initializes the "Attempt" object (stored in sleep mode). It fills the object below:
<class name="org.quiztool.model.Attempt" table="QT_ATTEMPTS"> <cache usage="transactional" /> <id name="id" type="long"> <generator class="native"> <param name="sequence">QT_ATTEMPTS_ID_SEQ</param> </generator> </id> <many-to-one name="quizId" class="org.quiztool.model.Quiz" cascade="none" /> <property name="score" type="int" not-null="true" /> <property name="outOf" type="int" not-null="true" /> <list name="responses" cascade="none" table="QT_RESPONSES" lazy="false"> <key column="id"/> <index column="idxr"/> <many-to-many class="org.quiztool.model.QuizAnswer" /> </list> <list name="questionList" cascade="none" table="QT_ATTEMPT_QUESTIONS" lazy="false"> <key column="id"/> <index column="idxq"/> <many-to-many class="org.quiztool.model.QuizQuestion" /> </list> <property name="userId" type="string" length="99" /> <property name="siteRole" type="string" length="99" /> <property name="startTime" type="java.util.Date" not-null="true" /> <property name="finishTime" type="java.util.Date" /> </class>
He randomly selects a set of questions and sets the start time and several other properties, and then redirects the user to the TakeTheQuiz page after saving the object through sleep mode.
On the TakeTheQuiz page, it loads the attempted object with its identifier, which is passed as a request parameter, then prints and formats it in html form so that the user can fill out the quiz. About 2/5 concurrent users will not see any questions. The attempted object is loading, and its questions are empty.
My theory is that the list of questions in the Tryempt object is either not immediately inserted into the database (this is normal as long as the object goes into the hibernate cache and I can get it from the cache, which I cannot see, to find out how to do it) OR it is stored in the database, but my object load on the TakeTheQuiz page reads an incomplete object from the cache.
Admittedly, my knowledge of Hibernate is limited, so if someone can help me understand what is going on here and how to fix it, let me know.
source share