-->
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: help in persisting polymorphic generic collections....
PostPosted: Sat Aug 29, 2009 7:36 am 
Newbie

Joined: Fri Aug 28, 2009 8:29 am
Posts: 3
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>


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.