Every Answer has a Question
Question knows all the Answers he has
If I retreive an Answer out of a HQL I can get the String attributes, but I can't get the Question object
answer.getStringAnswer() gives me the answer
answer.getQuestion() gives me NULL
Answer.java has the attributes
private Question question;
private int intAnswer;
private String stringAnswer;
private boolean booleanAnswer;
Question.java has the attributes
private List answers;
private String description;
private String answerType;
private boolean required;
Question.hbm.xml:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="com.xxess.platform.domain.Question" table="question">
<id name="id">
<generator class="native" />
</id>
<property name="description" type="java.lang.String"/>
<property name="answerType" type="java.lang.String" />
<property name="required" type="java.lang.Boolean" />
<bag name="answers" lazy="true" inverse="true" cascade="all">
<key column="question"/>
<one-to-many class="com.xxess.platform.domain.Answer" />
</bag>
</class>
</hibernate-mapping>
Answer.hbm.xml:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="com.xxess.platform.domain.Answer" table="Answer">
<id name="id">
<generator class="native" />
</id>
<property name="intAnswer" type="java.lang.Integer"/>
<property name="stringAnswer" type="java.lang.String" />
<property name="booleanAnswer" type="java.lang.Boolean" />
<many-to-one name="question" not-null="false" />
</class>
</hibernate-mapping>
I tried about everything, but nothing worked :{
What am I doing wrong here ?