Menu

#85 Types.BOOLEAN not recognized

closed-fixed
None
5
2008-08-10
2005-02-19
Berni
No

Using hibernate 1.7.2 i experienced an exception that
TYPES.BOOLEAN (16) is not recognized by dbunit 2.1
snapshot.

Copying BooleanDataType for Boolean2DataType and just
setting:

Boolean2DataType()
{
super("BOOLEAN", Types.BOOLEAN, Boolean.class,
false);
}

and registering Boolean2DataType in DataType like
BooleanDataType, the problem was fixed.

Discussion

  • Jon Skeet

    Jon Skeet - 2005-08-19

    Logged In: YES
    user_id=215483

    There's a slightly more pleasant way of dealing with this,
    IMO. Instead of adding a new type, change BooleanDataType's
    constructor to:

    BooleanDataType(String name, int sqlType)
    {
    super(name, sqlType, Boolean.class, false);
    }

    and change DataType.java to have:

    public static final DataType BOOLEAN = new BooleanDataType(
    "BOOLEAN", Types.BOOLEAN);
    public static final DataType BIT = new BooleanDataType(
    "BIT", Types.BIT);

    This reduces code duplication, and fits in with how other
    data types are implemented.

     
  • Uwe Kubosch

    Uwe Kubosch - 2006-11-28

    Logged In: YES
    user_id=34142
    Originator: NO

    Any progress on this? Seems like an easy fix?

     
  • Jol Blazey

    Jol Blazey - 2007-09-17

    Logged In: YES
    user_id=1892030
    Originator: NO

    We had a very similar problem to berni 123, and jskeet and we fixed it in almost exactly the same way. The problem was caused in dbunit 2.2 and hsqldb 1.8.0.7. hsqldb used boolean not BIT.

    Create a New class in datatypes package to represent true sql boolean
    ---------------
    public class RealSqlBooleanDataType extends BooleanDataType {

    RealSqlBooleanDataType\(\) \{
    

    super("BOOLEAN", Types.BOOLEAN);
    }
    }

    In existing BooleanDataType add a constructor for subclasses to call up to AbstractDataType
    so they can overide default BIT behaviour which is the cause of the bug
    --------------------
    public class BooleanDataType extends AbstractDataType
    {
    ......
    /**
    * Called from subclasses to pass though its values to super (as in skeet)
    */
    BooleanDataType(final String databaseDataType, final int dataTypesValue)
    {
    super(databaseDataType, dataTypesValue, Boolean.class, false);
    }

    Make 2 changes to this class to enable type checking iteration to pick up new RealSqlBooleanDataType()

    public abstract class DataType

    public static final DataType REAL_SQL_BOOLEAN = new RealSqlBooleanDataType();

    Add variable REAL_SQL_BOOLEAN to TYPES [] so that it gets iterated when checking sql column types in

    public static DataType forSqlType(int sqlType) throws DataTypeException

    in class DataType

    A FIX IN NEXT VERSION WOULD BE MUCH APPRECIATED! we have had to resort to our own build of dbunit with code fix as a work around.

     
  • Jol Blazey

    Jol Blazey - 2007-09-17

    Logged In: YES
    user_id=1892030
    Originator: NO

    Found in Dbunit 2.2. There is no Software Version field for this issue. Please note that we had the latest source and binary versions of dbunit (2.2) when we verified that this issue was present.

     
  • matthias g

    matthias g - 2008-08-10
    • assigned_to: rlogiacco --> gommma
    • status: open --> closed-fixed
     
  • matthias g

    matthias g - 2008-08-10

    Logged In: YES
    user_id=1803108
    Originator: NO

    I committed the fix for the upcoming 2.3 release and updated the unit tests. (svn rev. 783/trunk)

    Regards,
    mat

     

Log in to post a comment.