Entity inheritance with Nhibernate

Posts   
 
    
BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 17-May-2012 18:15:24   

Hi I have an entity Client representing an actual table in the database, i want to specialize it into other subtypes like IndividualClient based on the Client.IsIndividual = true. IndividualClient is not a physical table Using Inheritance Type : Target Per Entity Hierarchy

Problem is the validate entity check requires IndividualClient entity to map to a physical table

What am i doing wrong confused

Walaa avatar
Walaa
Support Team
Posts: 14954
Joined: 21-Aug-2005
# Posted on: 18-May-2012 01:14:32   

TargetPerEntityHierarchy does not require that subtypes should map to a physical table. TargetPerEntity does.

Could you change IsIdividual to another type (string, or int)?

BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 18-May-2012 12:08:08   

Walaa wrote:

TargetPerEntityHierarchy does not require that subtypes should map to a physical table. TrgetPerEntity does.

Could you change IsIdividual to another type (string, or int)?

Thanks it worked smile

Can i have more than on Discriminator field for a super type on the subtypes Say field isIndividual is used between Client and IndividaulClient and field Isguarantor is used for the subtype Guarantor which is also not mapped ?

Walaa avatar
Walaa
Support Team
Posts: 14954
Joined: 21-Aug-2005
# Posted on: 18-May-2012 12:13:16   

Just one Discriminator field. Try to mergethem both in one field.

BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 18-May-2012 12:45:52   

Walaa wrote:

Just one Discriminator field. Try to mergethem both in one field.

Where can i find this in the documentation or any examples you know online

Walaa avatar
Walaa
Support Team
Posts: 14954
Joined: 21-Aug-2005
# Posted on: 18-May-2012 14:57:39   

What do you want to find. When I say merge them, I mean logical wise, use one field to discriminate between different types, there is absolutly no reason to have 2 discriminator fields.

BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 18-May-2012 16:06:52   

Walaa wrote:

What do you want to find. When I say merge them, I mean logical wise, use one field to discriminate between different types, there is absolutly no reason to have 2 discriminator fields.

ok got the principal applied with discriminate fields

BHerbert
User
Posts: 12
Joined: 16-Jul-2011
# Posted on: 18-May-2012 16:15:00   

Another issue am facing here How can i add another entity to a typed list i have created when i add the 1st entity there are no more selection of entities allowed. Based on the documentation adding more entities should be possible

Iam using NHibernate ORM

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-May-2012 20:33:07   
  1. You create an entity: Project->New->Entity (Ctrl+Shift+E)
  2. Right click on that new entity and click on "Make subtype of...", then you select the base entity. More info here.
David Elizondo | LLBLGen Support Team