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 -->