openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <>
Subject Re: PersistenceException: Invalid character string format for type int
Date Thu, 24 Oct 2013 20:17:33 GMT
My finding so far is that the DerbyDictionary doesn't overwrite storeCharsAsNumbers, so it's
still defaulted to true.
This code is exactly which trashes in the sample

Caused by: java.sql.SQLDataException: Invalid character string format for type int.
        at Source)
        at Source)
        at Source)
        at org.apache.commons.dbcp.DelegatingResultSet.getInt(
        at org.apache.commons.dbcp.DelegatingResultSet.getInt(
        at org.apache.openjpa.lib.jdbc.DelegatingResultSet.getInt(
        at org.apache.openjpa.jdbc.sql.DBDictionary.getInt(
        at org.apache.openjpa.jdbc.sql.DBDictionary.getChar(
        at org.apache.openjpa.jdbc.sql.ResultSetResult.getCharInternal(
        at org.apache.openjpa.jdbc.sql.ResultSetResult.getObjectInternal(

The stacktrace is with todays 2.3.x branch snapshot.

    public char getChar(ResultSet rs, int column)
        throws SQLException {
        if (storeCharsAsNumbers)
            return (char) getInt(rs, column); <-- line 740 boom

The question for me is how Derby usually stores char fields internally. 
Is our DerbyDictionary just wrong and should it set storeCharsAsNumbers to false?

There is of course the option to use @ColumnDefinition in the entity. This should bypass this
flag (I hope, didn't test it yet).


----- Original Message -----
> From: Kay Wrobel <>
> To:
> Cc: 
> Sent: Thursday, 24 October 2013, 22:08
> Subject: PersistenceException: Invalid character string format for type int
> Dear OpenJPA Dev Team,
> I am getting this exception 
> <>

> while reading a simple entity DiscountCode from a Derby database called 
> SAMPLE (ships with Glassfish/NetBeans) called DISCOUNT_CODE that has 
> only two fields:
> DISCOUNT_CODE maps to type "Character" and RATE maps to 
> "BigDecimal". I 
> set up a Github <> 
> with a small test project. It's really small and concise. All you need 
> to run this is a running Derby Network server with the SAMPLE database 
> (included on the github), the latest OpenJPA library (I tested so far: 
> 2.2.0 shipping with TomEE 1.5.2, 2.2.2 from the main project page, and 
> 2.3.0-SNAPSHOT), the derby client driver (derby.jar, derbyclient.jar, 
> derbynet.jar from the main Apache Derby distribution) and that's it.
> The curious part is that the field DiscountCode, though a char field, 
> contains numeric, integer values. Mark Struberg seems to have a hunch 
> already of what is going on and is able to add some more insight.
> Any input on this is greatly appreciated.
> Regards,
> Kay Wrobel

View raw message