The problem is that Castor SQLEngine attempts to set NULL VARCHAR fields as CHAR sql 
datatype. Not all JDBC drivers correctly perform 
java.sql.PreparedStatement::setNull(int paramIndex,  int sqlType), where sqlType is 
java.sql.Types.CHAR and actual field type is VARCHAR or LONG VARCHAR. I'm trying to 
use Castor with Cloudscape, database.xml: <database name="..." engine="generic" >. 
Everything works fine meanwhile, except the described above situation.
I see it's not a bug. I hope it can be readily corrected. 

[mapping.xml]
  <class name="generated.Topic" identity="id">
    <map-to table="topic" />
    <field name="id" type="integer">
      <sql name="id" type="integer"/>
    </field>
    <field name="title" type="integer">
      <sql name="title" type="varchar"/>
    </field>
    <field name="abstract" type="string">
      <sql name="abstract" type="varchar"/>
    </field>
</class>

[source code]
...
db.begin();
Topic topic = new Topic();
topic.setId(1);
topic.setTitle("Title");
db.create(topic);    // org.exolab.castor.jdo.PersistenceException see below
db.commit();
...

[generated sql]
SQL for creating generated.Topic: INSERT INTO topic (id,title,abstract) VALUES (?,?,?)

[detailed exception]
org.exolab.castor.jdo.PersistenceException: Nested error: SQL Exception: Attempt to 
set parameter 3 to null type 'CHAR' when actual type is 'VARCHAR'.
SQL Exception: Attempt to set parameter 3 to null type 'CHAR' when actual type is 
'VARCHAR'.
 at RmiJdbc.RJPreparedStatementServer_Stub.setNull(Unknown Source)
 at RmiJdbc.RJPreparedStatement.setNull(RJPreparedStatement.java:95)
 at org.exolab.castor.jdo.engine.SQLEngine.create(SQLEngine.java:575)
 at org.exolab.castor.persist.ClassMolder.create(ClassMolder.java:885)
 at org.exolab.castor.persist.LockEngine.create(LockEngine.java:458)
 at org.exolab.castor.persist.TransactionContext.create(TransactionContext.java:794)
 at org.exolab.castor.jdo.engine.DatabaseImpl.create(DatabaseImpl.java:338)

Thanks 
Dmitry V.

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

Reply via email to