i searched the forum regarding this topic.... it may simpler ... but i cant able to make it....
below are my classes...... MyRack class has a list of Discs..... I don know how to write mapping file for this persistant class......
Code:
public class MyRack {
private String rackId;
private String location;
private List<Disc> discs;
public String getRackId() {
return rackId;
}
public void setRackId(String rackId) {
this.rackId = rackId;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public List<Disc> getDiscs() {
return discs;
}
public void setDiscs(List<Disc> discs) {
this.discs = discs;
}
}
Code:
public class Disc {
private String id;
private String capacity;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCapacity() {
return capacity;
}
public void setCapacity(String capacity) {
this.capacity = capacity;
}
}
Code:
public class AudioDisk extends Disc{
private String musicBy;
public String getMusicBy() {
return musicBy;
}
public void setMusicBy(String musicBy) {
this.musicBy = musicBy;
}
}
Code:
public class VideoDisk extends Disc{
private String movieName;
public String getMovieName() {
return movieName;
}
public void setMovieName(String movieName) {
this.movieName = movieName;
}
}
Code:
Database tables
Rack
rackId
location
RackDiscs
rackId
discId
discType
AudioDisk
discId
capacity
musicBy
VideoDisk
discId
capacity
movieName
can somebody help me how to write inheritance mapping inside a <list> or <bag> tag in hbm mapoping file........
below is my Disc.hbm.xml
Code:
<hibernate-mapping>
<class name="Disc">
<id name="id" type="string" column="diskid">
</id>
<property name="capacity" type="string" column="capacity">
</property>
<union-subclass name="AudioDisk" table="audiodisk">
<property name="musicBy" column="musicby"></property>
</union-subclass>
<union-subclass name="VideoDisk" table="videodisk">
<property name="movieName" column="moviename"></property>
</union-subclass>
</class>
</hibernate-mapping>
below is my MyRack.hbm.xml
Code:
<hibernate-mapping>
<class name="MyRack" table="rack">
<id name="rackId" type="string" column="rackid">
</id>
<property name="location" type="string" column="location">
</property>
<list>this is the place confusing me...</list>
</class>
</hibernate-mapping>