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.  [ 1 post ] 
Author Message
 Post subject: Recursive table
PostPosted: Thu Feb 10, 2005 12:17 pm 
Newbie

Joined: Wed Jan 19, 2005 6:41 am
Posts: 7
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

hi!
i want to create a table that it has a refrence to it or is Recursive table.
but hibernate dont create a field that refrence to it

in this example i have a table zone that has a field (parentID) refrence to a record in the zone table .

example:City has a parent Country . they are in zone table

package domain.zone;

import java.awt.Image;
import java.util.Set;


public class Zone {
private int id;

private String Code;

private int Type;

private String Name;

private Zone parentID;

private String Description;

public Zone() {
}

public Zone(String Code, int Type, String Name, Zone parentID,
String Description, Image map) {
this.Code=Code;
this.Type=Type;
this.Name=Name;
this.parentID=parentID;
this.Description=Description;
this.map=map;
}

......setter and getter methods

}


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="domain.zone">
<class name="Zone" table="zone">

<id name="id">
<generator class="sequence">
</generator>
</id>
<property name="code" not-null="true"/>
<property name="description"/>
<property name="name" not-null="true"/>
<one-to-one name="parentID" class="domain.zone.Zone"/>
<property name="type" not-null="true"/>
</class>

</hibernate-mapping>
<!-- parsed in 0ms -->


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

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.