-->
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.  [ 3 posts ] 
Author Message
 Post subject: Foreign Keys and Beans
PostPosted: Thu Mar 11, 2004 9:06 pm 
Newbie

Joined: Thu Mar 11, 2004 8:47 pm
Posts: 2
Is it necessary to have an attribute that corresponds to the foreign-key to its parent object, defined in a bean?

To illustrate, I have a class:

Code:
class Window
{
   private List holes; // List of Holes
   // accessor and mutators
}


and another:
Code:
class Hole
{
   private boolean isBufferOverflow;
   // accessor and mutators
}


In order to persist this, should I be able to simply create:
Code:
<hibernate-mapping package="">
  <class name="Window" table="WINDOW">
    <set name="holes" cascade="all" inverse="false" lazy="false">
      <one-to-many class="Hole"/>
    </set>
  </class>
  <class name="Hole" table="HOLE">
    <property name="isBufferOverflow" column="BUFFER_OVERFLOW" />
  </class>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 9:10 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
Yes, except you should declare your "holes" variable as a Set rather than a List, if you want it to match your mapping.

Also, read chapter 7 of the reference manual MANY TIMES :-)

Cheers!
Rob


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 7:48 pm 
Newbie

Joined: Thu Mar 11, 2004 8:47 pm
Posts: 2
Thanks Rob! That solved this problem.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.