Hmm, That article suggested that I make the Set available and to make sure that Castor is not getting a copy of the collection. I initialized a HashSet for the local veriable and that had no effect. I have also tried to provide an adder method to the mapping file description and that has no effect either. Any other idea's are welcome.
Bryan Excellent, that also brings me to think that if I marshal to xml I should look at the Set implementation that Hibernate uses for lazy loading and make sure that I treat it properly as well. I prefer to use Castor for the xml side because it is easier to manage changes to the schema than JAXB as suggested by the Hibernate folks. Thanks Bryan ----- Original Message ----- From: "Keith Visco" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, November 16, 2005 11:32 PM Subject: Re: [castor-user] mapping java.util.Set doesn't pull in all items > > Hi Bryan, > > Take a look at this thread, it may be a similar issue: > > http://www.mail-archive.com/[email protected]/msg01623.html > > --Keith > > > > [EMAIL PROTECTED] wrote: > > Hi, > > I am getting a curious result with my mapping file. it will > > only return one TestQuestion and in turn only a single > > QuestionChoice from an Exam. There are many more but the > > collection only has 1 entry. No errors occur so I am not sure > > what I am doing wrong. The classes are also mapped to a > > datasource using hibernate. All the getters and setters are in > > an parent class. Any idea's are welcome. > > > > Castor-0.9.9 > > winXP > > eclipse3.0.1 > > > > > > ----Main method from Java class --------- > > > > Unmarshaller um = new Unmarshaller(Exam.class); > > Mapping mapping = new Mapping(); > > mapping.loadMapping(new > > InputSource(um.getClass().getResourceAsStream("mapping.xml"))); > > um.setMapping(mapping); > > Exam exam = (Exam) um.unmarshal(new > > InputSource(um.getClass().getResourceAsStream("exam.xml"))); > > > > > > Iterator i = exam.getTestQuestions().iterator(); > > System.out.println(exam.getTestQuestions().size()); > > while (i.hasNext()) { > > TestQuestion tq = (TestQuestion) i.next(); > > System.out.println("[getQuestiontext]: " + > > tq.getQuestiontext()); > > > > Iterator i1 = tq.getQuestionChoices().iterator(); > > while (i1.hasNext()) { > > QuestionChoice qc = (QuestionChoice) > > i1.next(); > > System.out.println("[getChoicetext]: " + > > qc.getChoicetext()); > > } > > } > > > > ----mapping.xml----- > > <?xml version="1.0" encoding="UTF-8"?> > > > > <mapping> > > > > <description>Castor generated mapping file</description> > > > > <class name="com.campuspartners.webexit.dao.Exam"> > > > > <description> > > > > Default mapping for class > > > > com.campuspartners.webexit.dao.Exam > > > > </description> > > > > <map-to xml="exam" /> > > > > <field name="testQuestions" > > type="com.campuspartners.webexit.dao.TestQuestion" > > > > collection="set"> > > > > <bind-xml name="test-question"/> > > > > </field> > > > > <field name="testType" type="java.lang.String"> > > > > <bind-xml name="test-type" node="attribute" /> > > > > </field> > > > > <field name="examid" type="java.lang.Integer"> > > > > <bind-xml name="examid" node="attribute" /> > > > > </field> > > > > <field name="name" type="java.lang.String"> > > > > <bind-xml name="name" node="attribute" /> > > > > </field> > > > > </class> > > > > <class name="com.campuspartners.webexit.dao.TestQuestion"> > > > > <description> > > > > Default mapping for class > > > > com.campuspartners.webexit.dao.TestQuestion > > > > </description> > > > > <map-to xml="test-question" /> > > > > <field name="questionChoices" > > type="com.campuspartners.webexit.dao.QuestionChoice" > > > > collection="set"> > > > > <bind-xml name="question-choice"/> > > > > </field> > > > > <field name="questionsequence" type="java.lang.Short"> > > > > <bind-xml name="question-sequence" node="attribute" /> > > > > </field> > > > > <field name="testtype" type="java.lang.String"> > > > > <bind-xml name="test-type" node="attribute" /> > > > > </field> > > > > <field name="questiontype" type="java.lang.String"> > > > > <bind-xml name="question-type" node="attribute" /> > > > > </field> > > > > <field name="contexttext" type="java.lang.String"> > > > > <bind-xml name="context-text" node="attribute" /> > > > > </field> > > > > <field name="questionid" type="java.lang.Integer"> > > > > <bind-xml name="questionid" node="attribute" /> > > > > </field> > > > > <field name="questiontext" type="java.lang.String"> > > > > <bind-xml name="question-text" node="attribute" /> > > > > </field> > > > > </class> > > > > <class name="com.campuspartners.webexit.dao.QuestionChoice"> > > > > <description> > > > > Default mapping for class > > > > com.campuspartners.webexit.dao.QuestionChoice > > > > </description> > > > > <map-to xml="question-choice" /> > > > > <field name="choiceseq" type="java.lang.Short"> > > > > <bind-xml name="choice-seq" node="attribute" /> > > > > </field> > > > > <field name="choicetext" type="java.lang.String"> > > > > <bind-xml name="choice-text" node="attribute" /> > > > > </field> > > > > <field name="choicecorrectind" type="java.lang.Byte"> > > > > <bind-xml name="choice-correct-ind" node="attribute" /> > > > > </field> > > > > <field name="questionid" type="java.lang.Integer"> > > > > <bind-xml name="questionid" node="attribute" /> > > > > </field> > > > > <field name="choiceid" type="java.lang.Integer"> > > > > <bind-xml name="choiceid" node="attribute" /> > > > > </field> > > > > </class> > > > > </mapping> > > > > > > > > --------sample from > > exam.xml-------------------------------------------------------------------- ----------------------------------------- > > > > <?xml version="1.0" encoding="UTF-8"?> > > > > <exam name="Federal Perkins loan" test-type="p"> > > > > <test-question test-type="p" context-text="" question-sequence="1" > > > > question-text="Failure to repay my Federal Perkins loan will > > not have any negative impact on my credit rating." > > > > question-type="b"> > > > > <question-choice choice-correct-ind="0" choice-seq="1" > > > > choice-text="True" /> > > > > <question-choice choice-correct-ind="1" choice-seq="2" > > > > choice-text="False" /> > > > > </test-question> > > > > More test-questions .................. > > > > </exam> > > > > ------------------------------------------------- > > If you wish to unsubscribe from this list, please > > send an empty message to the following address: > > > > [EMAIL PROTECTED] > > ------------------------------------------------- > > > > > > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- > > ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] ------------------------------------------------- ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] -------------------------------------------------

