Hi Everybody!
I am a newabie to Hibernate and have my first greater problem with a many-to-one association on the same object :
Following Situation:
I have a abstract superclass "Status", and two subclasses "CustomerStatus" and "ReservationStatus".The abstract superclass inherits a list "SuccStatus" in which status objects are being held, which are the successor stati. That means that one status object has a list of its successor stati as an list object.
The Status Class:
public abstract class Status extends ID implements java.io.Serializable {
// Fields
private String name;
private String typ;
private Set succStatus;
private String iconName;
// Constructors
/** default constructor */
public Status() {
}
// Property accessors
...
public Set getSuccStatus() {
return succStatus;
}
public void setSuccStatus(Set succStatus) {
this.succStatus = succStatus;
}
...
}
the Hibernate Mapping (iki use the Table per ClassHierachie Pattern):
<hibernate-mapping>
<class name="hostelStar.model.Status" table="status" catalog="hostelstar">
<id name="id" type="java.lang.Long">
<column name="ID" />
<generator class="increment" />
</id>
<discriminator column="TYP" type="string"/>
...
<set name="succStatus" table="status_status" lazy="true" cascade="save-update">
<key column="ID" />
<many-to-many class="hostelStar.model.Status" column="SUCC_STATUS_ID"/>
</set>
<subclass name="hostelStar.model.ReservationStatus" discriminator-value="ResStatus">
...
</subclass>
<subclass name="hostelStar.model.CustomerStatus" discriminator-value="CustStatus">
...
</subclass>
</class>
</hibernate-mapping>
In the DB i have i single table which maps the successor relation; its a "mapping table"
ID is the id from the class
SUCC_STATUS_ID is the ID of the Successor Status
ID | SUCC_STATUS_ID
1 2
1 3
2 4
end so on
When i retrieve a status object from the db there are no entries in the list, although der are entries in the DB. I have tried several versions of mapping the set of successor stati but no one has filled the list.
What is wrong on my mapping file!
Thanks a lot for your support!
|