-->
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.  [ 2 posts ] 
Author Message
 Post subject: Distribute same class to two collections upon discriminator?
PostPosted: Fri Aug 03, 2007 10:28 am 
Newbie

Joined: Fri Aug 03, 2007 10:18 am
Posts: 1
Hi there,

I'm kind of newbie in NHibernate and have a question regarding collections vs discriminator:

I have three classes, Budget, BudgetGroup and BudgetRecord - they are organized as follows:

Budget contains a list of BudgetGroup and BudgetGroup contains a list of BudgetRecord, ie. a Budget can contain many BudgetGroups which again can contain several BudgetRecords.

BudgetGroup is either of income type or expense type, determined by field BudgetGroupType.

Now... Is it possible to have NHibernate load a BudgetGroup into one collection(of BudgetGroup) if its of type Income and into another collection(of BudgetGroup) if its of type Expense?

In native English: I would like to load a bunch of BudgetGroup's into two collections(of BudgetGroup) based on the kind of BudgetGroup(Income or Expense)?

Yep, you can always define two BudgetGroups, BudgetGroupExpense and BudgetGroupIncome and use a discriminator value - but can it be done without having to define two different classes, basically identical?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 03, 2007 3:29 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Yes, you can use the where='' in your collection element. See here.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.