• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mapping a list based on a discriminator

 
Chris Voyles
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Timecard Object that contains an ArrayList of TimecardRow objects. There are two subclasses of TimecardRow, ProductiveRow and NonproductiveRow. I have mapped a discriminator to determine which type of TimecardRow they are. Now I want to map a list from within the parent (Timecard) that only contains the rows containing productive time, but when I do a read from the database, the ArrayList always contains all TimecardRow objects, ignoring the discriminator. Can anyone give me any hints as to how I can fix it?

Here's the TimecardRow.hbm.xml


Here is the Timecard.hbm.xml

I am using the following code to read the database and cycle through the list:



The Timecard record I am reading has 2 productive rows and 1 nonproductive rows. The resulting ArrayList has 4 records. one Null, and all 3 TimecardRow records. The output is:

productive rows: 4
null
class iepa.timekeeping.ProductiveRow
class iepa.timekeeping.ProductiveRow
class iepa.timekeeping.ProductiveRow


If I change the many-to-one class in the TimecardRow mapping to TImecardRow, the output is:
productive rows: 4
null
class iepa.timekeeping.ProductiveRow
class iepa.timekeeping.ProductiveRow
class iepa.timekeeping.NonproductiveRow
[ September 27, 2006: Message edited by: Chris Voyles ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic