The SQL generated by castor when doing updates include a where clause
that compares all of the fields in the table not just the PK. This
causes problems when some of the fields are CLOB/TEXT etc... Is there a
way to prevent castor doing this? And why does it do it anyway?


Example:
Given the following mapping :

        <class name="ourcommunity.template.dao.TemplateDO" identity="id"
            key-generator="IDENTITY"> 
        <cache-type type="unlimited" />    
        <map-to table="Template" />
    
        <field name="id" type="integer" >
            <sql name="ID" type="integer"/>
        </field>

        <field name="name" type="string"  >
            <sql name="Name" type="varchar" />
        </field>

        <field name="description" type="string" >
            <sql name="Description" type="varchar" />
        </field>
    
        <field name="code" type="string" >
            <sql name="Code" type="varchar" />
        </field>
    </class>

Castor generates the following query for an update:

UPDATE "Template" SET "Name"=?,"Description"=?,"Code"=? WHERE "ID"=? AND
"Name"=? AND "Description"=? AND "Code"=?

The problem is that the "Code" field is of SQLServer text type which
cant be compared. so when castor attempts to the update it ends up
throwing this exception:

org.exolab.castor.jdo.PersistenceException: Nested error:
java.sql.SQLException: [SLOTH]The text, ntext, and image data types
cannot be compared or sorted, except when using IS NULL or LIKE
operator.


Shouldn't the query be ??

UPDATE "Template" SET "Name"=?,"Description"=?,"Code"=? WHERE "ID"=? 

why the extra comparisons in the WHERE clause?

Thanks

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

Reply via email to