-->
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.  [ 2 posts ] 
Author Message
 Post subject: Beginner mapping problem
PostPosted: Sat Mar 13, 2004 12:04 am 
Newbie

Joined: Sun Mar 07, 2004 12:27 am
Posts: 5
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2004 5:50 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
<many-to-one
name="courseLength"
column="course_length_id"
class="CourseLength"
outer-join ="true"
/>


you should take a look a outer-join and lazy attributes in the doc, it can help you


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

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.