tags:

views:

213

answers:

2

Hello I have a Subclass which needs to cover multiple Discriminator Values.

something like:

@DiscriminatorValue(value = "ACT","DNR","ATT" )

would do me perfect.

we have existing data where several discriminators can be mapped to one class (as they are similar types of what our system will consider the same thing)

+1  A: 

A subclass has exactly 1 discriminator value.

You can add additional subclasses under the existing subclass for the extra discriminator values. Subclasses need not have additional properties or behavior.

Lachlan Roche
+5  A: 

You can use DiscriminatorFormula:

// Base class
@DiscriminatorFormula("case when value in ('ACT','DNR','ATT') then 1 
   when 'OTH' then 2 else 3 end")

// Subclass 
@DiscriminatorValue("1") // maps to ACT, DNR, ATT
Brian Deterling
Perfect, exactly what OP asked for.
Lachlan Roche
Thanks a million Brian. I was doing this same thing but putting the @DiscriminatorFormula in the subclass . (Duh). This is working perfectly
Shaun Stone