This one time, at band camp, Micka�l Guessant said:

MG>Thanks for your analysis of the problem :-)
MG>
MG>There is some ongoing work on the SQLTypes that may solve the problem :
MG>http://bugzilla.exolab.org/show_bug.cgi?id=1130

Yes, this is exactly what will fix this problem. It's actually larger
than just String. The problem exists for any class that appears more
than once in the _typeInfos.

I'll be checking out Keith's patches very soon.

Bruce

MG>Thomas Olausson wrote:
MG>> Remember I talked about DB2 truncating strings to 256 bytes?
MG>> 
MG>> http://www.mail-archive.com/[email protected]/msg10523.html
MG>> 
MG>> That is still the case, but a friend of mine has found a fix:
MG>> Apparently, there's a bug in Castor on how String gets mapped to varchar.
MG>> No matter if you map String to varchar or longvarchar, the PreparedStatement in 
Castor maps the
MG>> datatype to CHAR anyway. DB2 truncates CHARs to 256, even if they are VARCHARs in 
the database.
MG>> 
MG>> !!
MG>> 
MG>> A long story made short, to map a String correctly to varchar, this change of 
order has to be made in:
MG>> org.exolab.castor.jdo.engine.SQLTypes
MG>> 
MG>>         new TypeInfo( java.sql.Types.VARCHAR,       "varchar",       
java.lang.String.class ),
MG>>         new TypeInfo( java.sql.Types.LONGVARCHAR,   "longvarchar",   
java.lang.String.class ),
MG>>         new TypeInfo( java.sql.Types.CHAR,          "char",          
java.lang.String.class ),
MG>> 
MG>> Notice varchar is before char.
MG>> Otherwise, the type will be mapped to the first hist in the list,  which is CHAR 
in the default distribution.
MG>> 
MG>> This method in the same class, needs to be worked on for that case:
MG>> 
MG>>  public static int getSQLType( Class javaType )
MG>>     {
MG>>         for ( int i = 0 ; i < _typeInfos.length ; ++i ) {
MG>>             if ( javaType.isAssignableFrom( _typeInfos[ i ].javaType ) )
MG>>                 return _typeInfos[ i ].sqlType;
MG>>         }
MG>>         return java.sql.Types.OTHER;
MG>>     }
MG>> 
MG>> /Thomas
MG>> 
MG>> ----------------------------------------------------------- 
MG>> If you wish to unsubscribe from this mailing, send mail to
MG>> [EMAIL PROTECTED] with a subject of:
MG>>    unsubscribe castor-dev
MG>> 
MG>> 
MG>> 
MG>
MG>
MG>

-- 
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

Reply via email to