-->
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: persistent directory listing
PostPosted: Tue Dec 09, 2003 6:11 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
I've tried to make a directory listing persistent with Hibernate, meaning that one directory may have several subdirectories, each of them having subdirectories as well.

I have one class as well as one table which might look like this:
Code:
CREATE TABLE mydirectory (
  id bigint(20) NOT NULL auto_increment,
  name varchar(255) NOT NULL default '',
  parent_id bigint(20),
  PRIMARY KEY  (id),
  KEY par (parent_id),
  FOREIGN KEY (`parent_id`) REFERENCES `mydirectory` (`id`)
) TYPE=InnoDB;

Making the relationship bi-directional (see chapter 9 of reference manual) seems to work, but how about a uni-directional relationship?
Is this possible with hibernate and how would the mapping look like?

Unfortunately, I haven't found an examples concerning this topic...

Thanks for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 11:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
From parent to child

<set>
...
<one-to-many class="Child" inverse="false" .../>
</set>

From child to parent
<many-to-one .../>

_________________
Emmanuel


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.