-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Mapping Lists
PostPosted: Thu Mar 30, 2006 1:58 am 
Beginner
Beginner

Joined: Wed Mar 01, 2006 11:26 pm
Posts: 23
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.