DBSpeicherbar:
Code:
package appl;
class DBSpeicherbar {
private long oid = -1;
DBSpeicherbar() {}
final long getOid() { return this.oid; }
final void setOid(final long i_oid) { this.oid = i_oid; }
}
Person:
Code:
package appl;
public final class Person extends DBSpeicherbar {
private String name;
private List<Adresse> adressen = new ArrayList<Adresse>();
Jaeger() {}
public final String getName() { return this.name; }
public final List<Adresse> getAdressen() { return this.adressen; }
final void setAdressen(final List<Adresse> i_adressen) { this.adressen = i_adressen; }
final void setName(final String i_name) { this.name = i_name; }
}
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="appl.Person" table="PERSON">
<id name="oid" type="java.lang.Long">
<column name="OID" sql-type="BIGINT"/>
<generator class="native" />
</id>
<property name="name">
<column name="NAME"/>
</property>
<list name="adressen" table="ADRESSEN" cascade="save-update, delete">
<key column="ID_JAEGER" />
<list-index column="SORTIERUNG" />
<one-to-many class="appl.Adresse" />
</list>
</class>
</hibernate-mapping>
Adresse:
Code:
package appl;
public final class Adresse extends DBSpeicherbar {
private String strasseHausnummer;
private String plz;
private String stadt;
Adresse() {
this("", "", "");
}
public final String getStrasseHausnummer() { return this.strasseHausnummer; }
public final String getPlz() { return this.plz; }
public final String getStadt() { return this.stadt; }
final void setStrasseHausnummer(final String i_strasseHausnummer) { this.strasseHausnummer = i_strasseHausnummer; }
final void setPlz(final String i_plz) { this.plz = i_plz; }
final void setStadt(final String i_stadt) { this.stadt = i_stadt; }
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="appl.Adresse" table="ADRESSEN">
<id name="oid" type="java.lang.Long">
<column name="OID" sql-type="BIGINT"/>
<generator class="native" />
</id>
<property name="strasseHausnummer">
<column name="STRASSE_HAUSNUMMER"/>
</property>
<property name="plz">
<column name="PLZ"/>
</property>
<property name="stadt">
<column name="STADT"/>
</property>
</class>
</hibernate-mapping>