Hi there
Im tring to map a list to a recordset that is returned from a SELECT statement but cant quite seem to get it.
Esentially all I tring to do is create an new class for each unique QuestionID, create a new object called DefinedAnswers for each associated AnswereID and then add DefinedAnswer object to a List contaied within the parent QuestionID. Does this make sense.
At present All I seem to be getting is the PropertyAccessException
Mapping documents: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-access="property" default-lazy="false" package="com.pctfiler.wizard">
<class name="Question"> <id name="questionId" type="string" />
<bag name="definedAnswers"> <key column="answerId" unique="false" /> <one-to-many class="DefinedAnswer" /> </bag> <loader query-ref="SpecialQuestions" /> </class>
<class name="DefinedAnswer"> <id name="answerId" column="answerId" /> <many-to-one class="Question" name="answerId" column="questionId" not-found="ignore" insert="false" update="false" /> <loader query-ref="SpecialQuestions" /> </class>
<sql-query name="SpecialQuestions" cacheable="false"> <load-collection alias="def" role="Question.definedAnswers" /> <return lock-mode="read" alias="quest" class="Question"> <return-property name="questionId" column="QuestionID" /> </return> SELECT q.QuestionID, q.Question, cqa.AnswerID FROM prod_cty_sections pcs INNER JOIN sections s ON pcs.SectionID = s.SectionID INNER JOIN questions q ON s.SectionID = q.SectionID LEFT JOIN closed_question_answers cqa ON q.QuestionID = cqa.QuestionID WHERE pcs.countryID IN (:CountryList) ORDER BY s.SortNumber, q.SortNumber, cqa.SortNumber </sql-query> </hibernate-mapping>
org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.pctfiler.wizard.DefinedAnswer.setAnswerId
MySQL 5.0
Hibernate: SELECT q.QuestionID, q.Question, cqa.AnswerID FROM prod_cty_sections pcs INNER JOIN sections s ON pcs.SectionID = s.SectionID INNER JOIN questions q ON s.SectionID = q.SectionID LEFT JOIN closed_question_answers cqa ON q.QuestionID = cqa.QuestionID WHERE pcs.countryID IN (?) ORDER BY s.SortNumber, q.SortNumber, cqa.SortNumber
[b]+------------+----------+
| QuestionID | AnswerID |
+------------+----------+
| IS | EUPO |
| IS | USPO |
| IPE | YES |
| IPE | NO |
| CO | YES |
| CO | NO |
| COEMP | 1TO20 |
| COEMP | 21TO500 |
| COEMP | OVER500 |
| PGDR | NULL |
| PGTX | NULL |
| CLTTL | NULL |
+------------+----------+[b]
I appreciated any help given
Thanks
Chris
|