geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gianny Damour <gianny.dam...@optusnet.com.au>
Subject Re: access a character column from a CMP EJB
Date Wed, 19 Oct 2005 02:42:23 GMT
Hi Deepesh,

This is a bug: no binding was defined for the Java primitive type char 
or the sql type CHAR. A fix has just been committed to fix this problem. 
Unfortunately, this means that you will need to checkout and build 
OpenEJB and TranQL.

The other approach is to write a custom org.tranql.sql.TypeConverter 
handling the type conversions Character <-> String. It looks like (not 
tested):
public class CharacterToStringConverter implements TypeConverter {
    public Object convertJavaToSQLType(Object opaque) throws 
TypeConversionException {
        Character value = (Character) opaque;
        if (null == value) {
            return null;
        }
        return character.toString();
    }
   
    public Object convertSQLToJavaType(Object opaque) throws 
TypeConversionException {
        String value = (String) opaque;
        if (null == value || 0 == value.length()) {
            return null;
        }
        return new Character(value.charAt(0));
    }
}

Then, you need to use it like this::
<sql-type>VARCHAR</sql-type>
<type-converter>CharacterToStringConverter</type-converter>

Thanks,
Gianny


On 18/10/2005 2:31 PM, Deepesh wrote:

>Hi,
>
>  I forget to post the full stack trace.
>
>here is the full stack trace without adding the
><sql-type>CHAR</sql-type>
>       
><type-converter>org.tranql.sql.typeconverter.SerializableConverter</type-converter>
>
>
>in openejb-jar.xml
>
>
>Caused by: org.tranql.ql.QueryException: Error
>executing statement: SELECT U.ACTIVE_FLAG FROM User U
>WHERE U.USER_ID = ?
>        at
>org.tranql.sql.jdbc.JDBCQueryCommand.execute(JDBCQueryCommand.java:79)
>        at
>org.tranql.cache.QueryFaultHandler.fieldFault(QueryFaultHandler.java:56)
>        at
>org.tranql.ejb.CMPFieldFaultTransform.get(CMPFieldFaultTransform.java:48)
>        ... 51 more
>Caused by: org.tranql.sql.TypeConversionException
>        at
>org.tranql.sql.typeconverter.SerializableConverter.convertSQLToJavaType(SerializableConverter.java:60)
>        at
>org.tranql.sql.jdbc.binding.TypeConverterBinding.getValue(TypeConverterBinding.java:81)
>        at
>org.tranql.sql.jdbc.binding.TypeConverterBinding.getValue(TypeConverterBinding.java:85)
>        at
>org.tranql.sql.jdbc.JDBCQueryCommand.execute(JDBCQueryCommand.java:72)
>        ... 53 more
>
>
>
>Regards,
>
>Deepesh
>
>
>		
>__________________________________________________________ 
>Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com
>
>
>  
>



Mime
View raw message