Ole,

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.

Try it out and if it does work please update the Firebird type in the 
standardjbosscmp-jdbc.xml file.

-dain

Ole Husgaard wrote:
> Hi,
> 
> (Please note that this problem could easily be
> avoided by using other types. But maybe a small
> change in the CMP engine and/or the Firebird driver
> would be better.)
> 
> I'm using JBoss from CVS about a week old, and
> firebird-jca-jdbc-driver 1.0-beta-1.
> 
> In my db, I have a column, defined as
>   SEX CHAR
> and I have CMP2.0 accessors for it in my bean
>   Character getSex();
>   void setSex(Character sex);
> 
> My problems start when I create an instance of my bean
> This provokes an exception in the Firebird driver:
>  org.firebirdsql.jdbc.TypeConvertionException: Error converting to object.
>       at org.firebirdsql.jdbc.FBField.setObject(FBField.java:601)
>       at 
>org.firebirdsql.jdbc.FBPreparedStatement.setObject(FBPreparedStatement.java:212)
>       at 
>org.firebirdsql.jdbc.FBPreparedStatement.setObject(FBPreparedStatement.java:382)
>       at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.setParameter(JDBCUtil.java:249)
>       at 
>org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setArgumentParameters(JDBCAbstractCMPFieldBridge.java:283)
>       at 
>org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setInstanceParameters(JDBCAbstractCMPFieldBridge.java:262)
>       at 
>org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.insertEntity(JDBCCreateEntityCommand.java:192)
>       at 
>org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.execute(JDBCCreateEntityCommand.java:131)
>       at 
>org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:527)
>       at 
>org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:253)
>       at 
>org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)
> (Line numbers may be slightly offset by extra debug code I inserted.)
> 
> At JDBCUtil.java:249, there is a call
>   pm.setObject(index, value, jdbcType);
> When this exception occurs, I can se that value is
> of class java.lang.Character with the value 'M', and
> that jdbcType is CHAR.
> 
> I'm not an JDBC expert, but it looks to me like throwing
> an exception in this case may actually not be a JDBC
> violation (JDBC has no standard mapping from Character
> to CHAR).
> 
> However, it seems logical to call the driver this way, so
> a change to the FBField class in the Firebird driver to
> allow this would be nice, and also simple to do.
> 
> And _if_ the Firebird driver already is JDBC-conformant
> on this issue, we should probably change the CMP2.0
> engine so that such a call is not done. That shouldn't
> be hard to do either, in the JDBCUtil.setParameter()
> method.
> 
> But before I do any of the above changes, I would like
> to hear your comments.
> 
> 
> Best Regards,
> 
> Ole Husgaard
> 
> 
> -------------------------------------------------------
> 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


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