Hi Bruce, thanks for your quick reply.

Adding dirty="ignore" to any fields with primitive type or Date fixed the
update() error.  (And, yes, I had figured out that update() is only used for
long transactions.)

However, I still get the null pointer when calling insert().

Here is a bit more on the error:

Caused by: org.exolab.castor.jdo.PersistenceException: Nested error:
java.lang.NullPointerException
        at org.exolab.castor.persist.TransactionContext.create(Unknown Source)
        at org.exolab.castor.jdo.engine.DatabaseImpl.create(Unknown Source)
        at com.xmlmodeling.portal.data.PortalUser.insert(PortalUser.java:41)

The Java classes were generated from an XML Schema using Castor source
generator, so they are a bit verbose to copy relevant parts.  Here is the
mapping.xml for the two classes involved in the inheritance.  I'm attempting to
insert the subclass, PortalUser.

Thanks again for your help!

<class name="com.xmlmodeling.sentinel.express.EndUserType"
    identity="endUserId" key-generator="IDENTITY">
<map-to table="MS_enduser" />
<field name="address" type="string">
<sql type="varchar" name="Address" />
</field>
<field name="active" type="integer">
<sql type="integer" name="Active" dirty="ignore" />
</field>
<field name="city" type="string">
<sql type="varchar" name="City" />
</field>
<field name="companyName" type="string">
<sql type="varchar" name="CompanyName" />
</field>
<field name="country" type="string">
<sql type="varchar" name="Country" />
</field>
<field name="endUserId" type="integer" required="true">
<sql type="integer" name="EnduserID" />
</field>
<field name="faxNumber" type="string">
<sql type="varchar" name="FaxNumber" />
</field>
<field name="firstName" type="string">
<sql type="varchar" name="FirstName" />
</field>
<field name="emailAddress" type="string" required="true">
<sql type="varchar" name="EmailAddress" />
</field>
<field name="homePhone" type="string">
<sql type="varchar" name="HomePhone" />
</field>
<field name="lastName" type="string">
<sql type="varchar" name="LastName" />
</field>
<field name="password" type="string" required="true">
<sql type="varchar" name="Password" />
</field>
<field name="postalCode" type="string">
<sql type="varchar" name="PostalCode" />
</field>
<field name="stateOrProvince" type="string">
<sql type="varchar" name="StateOrProvince" />
</field>
<field name="workPhone" type="string">
<sql type="varchar" name="WorkPhone" />
</field>
</class>

<class name="com.xmlmodeling.portal.data.PortalUser" identity="endUserId"
extends="com.xmlmodeling.sentinel.express.EndUserType">
<map-to table="Portal_PortalUser" />
<field name="endUserId" type="integer" required="true">
<sql type="integer" name="EnduserID" />
</field>
<field name="createDate" type="date">
<sql type="timestamp" name="CreateDate" dirty="ignore" />
</field>
<field name="lastLoginDate" type="date">
<sql type="timestamp" name="LastLoginDate" dirty="ignore" />
</field>
<field name="confirmValue" type="string">
<sql type="varchar" name="ConfirmValue" />
</field>
<field name="emailOptIn" type="boolean">
<sql type="integer" name="EmailOptIn" dirty="ignore" />
</field>
<field name="acceptLicenseHyperModel" type="boolean">
<sql type="integer" name="AcceptLicenseHyperModel" dirty="ignore" />
</field>
<field name="maxUploadSize" type="integer">
<sql type="integer" name="MaxUploadSize" dirty="ignore" />
</field>
</class>

----- Original Message -----
From: "Bruce Snyder" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 27, 2002 11:02 AM
Subject: Re: [castor-dev] errors with insert and update, JDO inheritance


> This one time, at band camp, Dave Carlson said:
>
> DC>I've configured two Java classes, one that extends another, and have
mapped
> DC>them to two SQL tables, one corresponding to each class.  The tables share
a
> DC>common primary key.  I can query the subclass and recieve an object that
> DC>includes all data from the tables representing both the super and
subclasses.
> DC>This works great.
> DC>
> DC>But I can't insert or update with these objects.  I want to work primarily
with
> DC>the subclass.  When I create a new Java object from the subclass and
insert it,
> DC>I get a null pointer exception, from this point:
> DC>
> DC>    org.exolab.castor.persist.TransactionContext.create()
> DC>
> DC>Any suggestions?
> DC>
> DC>Also, when I call update(), or simply modify the object within a
transaction, I
> DC>get an error
> DC>
> DC>Caused by: org.exolab.castor.jdo.ObjectModifiedException: Transaction
aborted:
> DC>Object of type com.xmlmodeling.portal.data.PortalUser with identity 1 has
been
> DC>modified by a concurrent transaction at
> DC>org.exolab.castor.jdo.engine.SQLEngine.store(Unknown Source)
> DC>
> DC>I saw a note that I must implement the jdo Timestampable interface for the
> DC>superclass of an inheritance structure, so I've done that.  But I don't
> DC>understand this error about concurrent transaction.  I only have one
> DC>transaction running.  I'm guessing there is something internal to JDO
handling
> DC>updates to the two tables representing this object.
> DC>
> DC>Thanks for any help on understanding the internals of JDO inheritance
> DC>processing!
>
> Dave,
>
> I don't follow your statement, 'The tables share a common primary key.'
Please
> clarify.
>
> The db.update() method is *only* for use with long transactions:
>
>     http://www.castor.org/long-transact.html
>
> When using long transactions, any objects involved in the long transaction
> must implement the TimeStampable interface so that Castor can perform it's
> dirty check.
>
> Without seeing the relevant portions of the mapping descriptor and client
> code, I can't really say why you're receiving an ObjectModifiedException.
> Oftentimes, this exception can be thrown for fields of type date, float
> and double because they're failing the dirty check. If you're using
> any of these types, utilizing the dirty="ignore" attribute of the <sql>
> element in the mapping descriptor can help in hunting down the culprit.
>
> Bruce
> --
> perl -e 'print
unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
>
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to