Hi,
I'm attempting to setup a couple of subclasses for my Order entity, CreditCardOrder and ComplementaryOrder. I believe that my mapping configurations are setup properly and the discriminator subclassing stuff is working. But, I've hit a snag doing inserts of my subclasses.
Our standard base Order class implements Hibernate's Lifecycle API. We need to perform a couple of tasks each time the object is saved (in the onSave() method).
For example, when I instaniate a CreditCardOrder object (which extends Order) and attempt to insert it, the Order.onSave() method is never called, causing the insert to fail because of a database constraint (this insert failure is due to a not null property that should be set in the onSave() method).
Does anyone know why this is happening?
Thanks in advance.
e.
Hibernate version: 2.1.6
Mapping documents:
Code:
<class name="com.mycompany.Order" table="ORDER">
<id name="orderId" type="long" column="ORDER_ID">
<generator class="sequence">
<param name="sequence">ORDER_SEQ</param>
</generator>
</id>
<discriminator
column="ORDER_TYPE_CODE"
type="string" />
.......
<property name="orderTypeCode"
type="java.lang.String"
update="false"
insert="false"
access="property"
column="ORDER_TYPE_CODE"
length="3">
</property>
<subclass
name="com.mycompany.CreditCardOrder"
discriminator-value="CCO"
dynamic-update="true"
dynamic-insert="true">
</subclass>
<subclass
name="com.mycompany.ComplimentaryOrder"
discriminator-value="COM"
dynamic-update="true"
dynamic-insert="true">
</subclass>
Name and version of the database you are using:
Oracle 9i