These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Lifecycle API not called from discriminator subclasses
PostPosted: Thu Nov 11, 2004 3:24 pm 
Newbie

Joined: Wed Jun 30, 2004 11:00 am
Posts: 7
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.