Hi--
I have two classes which map to the same table (mapping snippet is
attached). One class extends the other so that I can save on SQL JOIN
overhead for certain operations which dont require the complete set of
collected data... Selecting objects of either class works fine. Creating
new records however of the SUB class (Visitor) causes this problem:
java.sql.SQLException: ERROR: ExecAppend: Fail to add null value in not
null attribute ID
Is this because castor ignores key-generator parameters for sub-classes,
since they are supposed to use the same identity as their super class?
(I suspect this because trying to associate any key generator with the
sub class never creates a castor message denoting the instantiation of
that generator.)
So my problem is that I can only create new FastVisitor's and never
Visitor's. Since both classes have to use the same key gen, the only
solution I can think of is to create a FastorVisitor, get an ID, commit
the transaction then select out the same record as a Visitor. But I dont
want to do this for performance reasons.
Any other ideas?
Thanks
-Peter
<class name="FastVisitor"
identity="ID"
key-generator="visitor_seq"
access="shared">
<cache-type type="none"/>
<description>FastVisitor</description>
<map-to table="Visitor" xml="Visitor"/>
<field name="ID" type="integer">
<sql name="ID" type="integer"/>
<xml node="attribute"/>
</field>
<field name="Created" type="date">
<sql name="Created" type="timestamp"/>
<xml name="Created" node="element"/>
</field>
<field name="Updated" type="date">
<sql name="Updated" type="timestamp"/>
<xml name="Updated" node="element"/>
</field>
<field name="Tidbits"
type="Tidbit"
lazy="true"
collection="collection"
required="false">
<sql many-key="VisitorID" />
<xml name="Tidbits" node="element" />
</field>
<field name="ProgramEvents"
type="ProgramEvent"
lazy="true"
collection="collection"
required="false">
<sql many-key="VisitorID" />
<xml name="ProgramEvents" node="element" />
</field>
<field name="Email" type="string">
<sql name="Email" type="varchar"/>
<xml name="Email" node="element"/>
</field>
</class>
<class name="Visitor"
extends="FastVisitor"
access="shared">
<!--cache-type type="none"/-->
<cache-type type="count-limited" size="2500"/>
<description>Visitor</description>
<map-to table="Visitor" xml="Visitor"/>
<field name="Interests"
type="Interest"
lazy="true"
collection="collection"
required="false">
<sql many-key="VisitorID" />
<xml name="Interests" node="element" />
</field>
<field name="VisitorInternetDeviceAssociations"
type="VisitorInternetDeviceAssociation"
lazy="true"
collection="collection"
required="false">
<sql many-key="VisitorID" />
<xml name="VisitorInternetDeviceAssociations"
node="element" />
</field>
<field name="Referrals"
type="Referral"
lazy="true"
collection="collection"
required="false">
<sql many-key="FromVisitorID" />
<xml name="Referrals" node="element" />
</field>
</class>