Ole Husgaard wrote:
> Dain Sundstrom wrote:
> 
>>If you change the jdbc-type (not the sql-type) to VARCHAR, it should
>>work for you.  If the parameter type is a Character and the jdbc-type is
>>a VARCHAR, the parameter is converted into a string before setting, and
>>converted back into a character on get.  This code was added for
>>databases that don't support char types such as Oracle. This change does
>>not require that the database column type change.
> 
> 
> I guess you are talking about the change you made in
> JDBCUtil.coerceToSQLType().

Yes.

>>Try it out and if it does work please update the Firebird type in the
>>standardjbosscmp-jdbc.xml file.
> 
> 
> Letting the database column type be VARCHAR instead would
> probably work fine. Unfortunately my DB is pre-defined.

I'm not suggesting you change your database.  The jdbc-type is just the 
type that the container tells the JDBC driver to use in order to set the 
type.  It has nothing to do with the actual type of the column; the 
driver handled the type conversion.

> I'm not a JDBC expert, but it looks to me like there
> is no (JDBC-standard-) problem with the Firebird driver,
> since JDBC has no standard mapping from java.lang.Character
> to CHAR. However, there is a mapping from java.lang.String
> to CHAR.
> 
> My temporary workaround is similar to what you did with
> VARCHAR, only I do it each time, like changing
> JDBCUtil.coerceToSQLType() to say:
>   } else if(value.getClass() == Character.class)
> instead of:
>   } else if(value.getClass() == Character.class && 
>             jdbcType == Types.VARCHAR)
> (The only difference being that I do this conversion
> in JDBCUtil.setParameter(), just before the call
>   pm.setObject(index, value, jdbcType);
> With that change all my code runs fine, though I
> have not run the complete testsuite.)

If you change the jdbc-type (not your column type) to VARCHAR the code 
will work for you.

> It looks to me like the CMP engine would be more
> JDBC-conformant, if it always converts a Character
> to a String before setting a field.

Not necessarily.  Several databases are perfectly happy with Characters 
and CHAR jdbc-type.

> Is there any case where setting a String wouldn't
> work when a Character would?
> If not, we might as well always coerce Character
> to String.

I don't know.  Try changing the default jdbc-type for Firebird to 
VARCHAR and see if it works for Firebird.  If it does then, we don't 
need to change any code.

-- 
xxxxxxxxxxxxxxxxxxxxxxxx
Dain Sundstrom
Chief Architect JBossCMP
JBoss Group, LLC
xxxxxxxxxxxxxxxxxxxxxxxx



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Oh, it's good to be a geek.
http://thinkgeek.com/sf
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to