Using annotations version 3.4.0GA & hibernate version 3.3.2GA.
Per the hibernate documentation I can use a table per subclass with a discriminator (
http://docs.jboss.org/hibernate/stable/ ... criminator). I also need to specify a discriminator formula.
Is this supported via annotations? The annotation documentation refers to using the @DiscriminatorFormula with single table inheritance, not joined. Is this the only supported use via annotations? I haven't tried configuring this via xml yet so not sure if it works or not. I'd prefer to use annotations but I guess could use XML for this one thing if need be.
My reasoning for using a discriminator with a joined inheritance is performance (please correct if my understanding is off). I have a wide hierarchy (one base class, many subclasses) so using a single table doesn't make sense the vast majority of columns wouldn't be used for any given record. However, by default the join inheritance type joins against every single subclass table. This is unecessary as I can define which sub table would contain the data via a discriminator and hence only have to join with that one sub table.
My root entity looks like the following:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorFormula("(a formula...)")
@DiscriminatorValue(value = "base")
@Table(name = "config")
public class BaseConfig{
A sub entity is defined as follows:
@Entity
@Table(name = "sub_config")
@DiscriminatorValue(value = "subconfig")
public class SubConfig
When I run this the formula annotation appears to be ignored and the default case statement is generated to determine which class to use. Just want to know if I'm doing something wrong, or this use case just isn't supported via annotations.
Thanks,
Bob