Here is some code that may can help you.
I have written to classes and a mapping for each one.
I had only defined the propertys QuestionID and AnswerID.
In the Question class you have now a ISet, which contains all referenced Answers.
In the Answer class you have a Questionfield, which contains the referenced Question.
Hope that is what you want (Sample Code is in C#)
Class for the Question
public class Question
{
//other fields
private int _id;
private ISet<Answer> _answers;
//other props
public virtual int ID
{
get{ return _id; }
set{ _id = value; }
}
public virtual ISet<Answer> Answers
{
get
{
return _answers;
}
set
{
_answers = value;
}
}
}
Mapping for the Question
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="App.Question, App" table="question">
<id name="ID" column="questionid" type="int">
<generator class="native" />
</id>
<!--Other Propertys-->
<set name="Answers" table="answer" generic="true" inverse="true">
<key column="questionId" />
<one-to-many class="App.Answer, App"/>
</set>
</class>
</hibernate-mapping>
Class for the Answer
public class Answer
{
//other fields
private int _id;
private Question _question;
//other props
public virtual int ID
{
get{ return _id; }
set{ _id = value; }
}
public virtual Question Question
{
get
{
return _question;
}
set
{
_question = value;
}
}
}
Mapping for the Answer
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="App.Answer, App" table="answer">
<id name="ID" column="answerid" type="int">
<generator class="native" />
</id>
<!--Other Propertys-->
<many-to-one name="Question" column="questionId" class="App.Question, App"/>
</class>
</hibernate-mapping>