Hi. I have an object that holds an object of a different type inside it which also has its own table. I have mapped that object with a <many-to-one> relationship. When I save the "master" object it stores the proper id of the "slave" object.
The problem comes when I try to retrieve the master object from the database. The slave object is null, creating nullPointerExceptions all over the place.
Here is the mapping...
Code:
<hibernate-mapping package="slide.model">
<class name="Activity" table="activities">
<id name="id" type="long">
<generator class="native"/>
</id>
<!-- indentification -->
<property name="name" type="string" not-null="true"/>
<!-- dates -->
<property name="startDate" type="calendar_date"/>
<property name="endDate" type="calendar_date"/>
<many-to-one
name="courseLength"
column="course_length_id"
class="CourseLength"
/>
...............
</class>
</hibernate-mapping>
CourseLength is the slave object that I need returned in object form when I make a call to the database. I was told that many-to-one a good way to save objects. Do you guys have any other ideas???
Thanks for all your help.