I'm in the process of migrating a very large library from Hibernate 2.1 to Hibernate 3.5.
I have a few entities that map using the single table strategy and map to views within an Oracle DB.
In the 2.1 mapping file, I'm able to restrict insert on the discriminator value like so:
<discriminator column="FOO" type="string" insert="false" />
It doesn't appear that I'm able to use this same approach using JPA annotations.
My base class looks a bit like this:
@Entity @Table(name="V_BAR") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="FOO") public class Bar { ...
and my subclasses look a bit like this:
@Entity @DiscriminatorValue("S") public class SaladBar extends Bar{...
Can anyone describe a good approach to restricting inserts on the discriminator column?
The workaround I have implemented has been replacing @DiscriminatorColumn with @DiscriminatorFormula on the base class, so that the base class looks a bit like this:
@Entity @Table(name="V_BAR") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorFormula (value="FOO") public class Bar { ...
This seems to do the trick for now, but doesn't seem like the "proper" approach (and being a bit of a Hibernate / ORM newbie, I still need to do a bit of research into the whys and hows)
Thanks! ++dave;
|