Hibernate version:
HB3
Hi all,
I am trying to use a discriminator with a formula. I can see how the formula is used to evaluate what class to instantiate, but what is supposed to happen in the reverse direction, when saving a new persistant class?
example:
<discriminator
type="java.lang.String"
formula="case when Org_Type in ('A', B') then 'A' else 'C' end"
/>
If I try to persist an instance of the sub-class that should have a discriminator value of 'C', how would hibernate know to set the Org_Type column? I tried adding in the column attribute to the <discriminator> tag, but all examples I've seen either use "formula" or "column", but not both.
The problem I am getting when saving new objects is: cannot insert the value NULL into column 'org_type'. Hibernate does not seem to be populating the discriminator. Everything works fine if I don't use the formula, but I need this to support multiple discriminator values for one of my sub-classes.
I will post more details (mapping files, etc) if needed, but I would just like a general indication of whether this is supposed to work or not.
thanks very much,
Daniel.
|