Data type factory for Derby database.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Data type factory for Derby database.

Jeremy Whiting

Hello,
  I want to use Apache Derby to run some integration tests with DBUnit.

 Is there a Derby data type factory available ?

Jeremy

     
_________________________________________________________________
Did you know you can get Messenger on your mobile?
http://clk.atdmt.com/UKM/go/174426567/direct/01/
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Data type factory for Derby database.

Matthias Gommeringer
Hi Jeremy,

currently there is no special IDataTypeFactory implementation for Derby. The DefaultDataTypeFactory should do the job (you don't have to register anything for this). If you experience problems with it please let us know.

rgds,
matthias

> -----Ursprüngliche Nachricht-----
> Von: "Jeremy Whiting" <[hidden email]>
> Gesendet: 21.10.09 19:40:54
> An: <[hidden email]>
> Betreff: [dbunit-user] Data type factory for Derby database.


>
> Hello,
>   I want to use Apache Derby to run some integration tests with DBUnit.
>
>  Is there a Derby data type factory available ?
>
> Jeremy
>
>      
> _________________________________________________________________
> Did you know you can get Messenger on your mobile?
> http://clk.atdmt.com/UKM/go/174426567/direct/01/
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>


______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Data type factory for Derby database.

Jeremy Whiting
In reply to this post by Jeremy Whiting

Hello Matthias,
  Yes I am getting an error. I have a flat XML data set for a sample application. This is being loaded before some integration tests.
 The table record XML data contains a Boolean value for the column "IS_ADMIN".
 When DBUnit attempts to load the record into the database it barfs an exception.
 
This is the offending xml snipet

*************
    <USERS
        USER_ID             ="1"
        OBJ_VERSION         ="0"
        FIRSTNAME           ="John"
        LASTNAME            ="Doe"
        USERNAME            ="johndoe"
        PASSWORD            ="secret"
        EMAIL               ="[hidden email]"
        RANK                ="0"
        IS_ADMIN            ="TRUE"
        CREATED             ="2006-09-23 13:45:00"
        HOME_STREET         ="Foostreet"
        HOME_ZIPCODE        ="22222"
        HOME_CITY           ="Foocity"
        DEFAULT_BILLING_DETAILS_ID ="[NULL]"
    />

*************

and this is the exception

*************
   [testng] Failed to invoke @Configuration method auction.test.EJB3IntegrationTest.beforeTestMethod:Error casting value for table 'USERS' and column 'IS_ADMIN'
   [testng] FAILED: beforeTestMethod
   [testng] org.dbunit.dataset.datatype.TypeCastException: Error casting value for table 'USERS' and column 'IS_ADMIN'
   [testng]     at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:190)
   [testng]     at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
   [testng]     at auction.test.EJB3IntegrationTest.beforeTestMethod(Unknown Source)
   [testng] Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value <true> of type <java.lang.String> to SMALLINT
   [testng]     at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:81)
   [testng]     at org.dbunit.dataset.datatype.IntegerDataType.setSqlValue(IntegerDataType.java:106)
   [testng]     at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:73)
   [testng]     at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:63)
   [testng]     at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:186)
   [testng]     ... 25 more
   [testng] Caused by: java.lang.NumberFormatException
   [testng]     at java.math.BigDecimal.<init>(BigDecimal.java:455)
   [testng]     at java.math.BigDecimal.<init>(BigDecimal.java:724)
   [testng]     at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:77)
   [testng]     ... 29 more
   [testng] ... Removed 23 stack frames

*************

 I have not looked at the dbunit code. Is there an interceptor chain to handle the type mappings ?

Thanks,
Jeremy



Jeremy R. Whiting, Mobile: 07968722015, MSN: [hidden email], Skype: whitingjr


     
_________________________________________________________________
Download Messenger onto your mobile for free
http://clk.atdmt.com/UKM/go/174426567/direct/01/
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Data type factory for Derby database.

Jeremy Whiting
In reply to this post by Jeremy Whiting

Hello Matthias,
  Yes I am getting an error. I have a flat XML data set for a sample application. This is being loaded before some integration tests.
 The table record XML data contains a Boolean value for the column "IS_ADMIN".
 When DBUnit attempts to load the record into the database it barfs an exception.
 
This is the offending xml snipet

*************
    <USERS
        USER_ID             ="1"
        OBJ_VERSION         ="0"
        FIRSTNAME           ="John"
        LASTNAME            ="Doe"
        USERNAME            ="johndoe"
        PASSWORD            ="secret"
        EMAIL               ="[hidden email]"
        RANK                ="0"
        IS_ADMIN            ="TRUE"
        CREATED             ="2006-09-23 13:45:00"
        HOME_STREET         ="Foostreet"
        HOME_ZIPCODE        ="22222"
        HOME_CITY           ="Foocity"
        DEFAULT_BILLING_DETAILS_ID ="[NULL]"
    />

*************

and this is the exception

*************
   [testng] Failed to invoke @Configuration method auction.test.EJB3IntegrationTest.beforeTestMethod:Error casting value for table 'USERS' and column 'IS_ADMIN'
   [testng] FAILED: beforeTestMethod
   [testng] org.dbunit.dataset.datatype.TypeCastException: Error casting value for table 'USERS' and column 'IS_ADMIN'
   [testng]     at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:190)
   [testng]     at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
   [testng]     at auction.test.EJB3IntegrationTest.beforeTestMethod(Unknown Source)
   [testng] Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value <true> of type <java.lang.String> to SMALLINT
   [testng]     at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:81)
   [testng]     at org.dbunit.dataset.datatype.IntegerDataType.setSqlValue(IntegerDataType.java:106)
   [testng]     at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:73)
   [testng]     at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:63)
   [testng]     at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:186)
   [testng]     ... 25 more
   [testng] Caused by: java.lang.NumberFormatException
   [testng]     at java.math.BigDecimal.<init>(BigDecimal.java:455)
   [testng]     at java.math.BigDecimal.<init>(BigDecimal.java:724)
   [testng]     at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:77)
   [testng]     ... 29 more
   [testng] ... Removed 23 stack frames

*************

 I have not looked at the dbunit code. Is there an interceptor chain to handle the type mappings ?

Thanks,
Jeremy



Jeremy R. Whiting, Mobile: 07968722015, MSN: [hidden email], Skype: whitingjr


     
_________________________________________________________________
Chat to your friends for free on selected mobiles
http://clk.atdmt.com/UKM/go/174426567/direct/01/
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Data type factory for Derby database.

Matthias Gommeringer
In reply to this post by Jeremy Whiting
Hi Jeremy,

as kind of an interceptor you can write a custom "DerbyDataTypeFactory" implementation (similar to the existing ones for Oracle/MySQL etc.) to control the java datatypes to be used for which DB column type:

    <code>
    import org.dbunit.dataset.datatype.DefaultDataTypeFactory;
    public class DerbyDataTypeFactory extends DefaultDataTypeFactory {
        public DataType createDataType(int sqlType, String sqlTypeName) {
            return super.createDataType(sqlType, sqlTypeName);
        }
        ....
    }
    </code>

then register it with your DatabaseConnection:

    <code>
    DatabaseConnection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new DerbyDataTypeFactory());
    </code>

and debug into the method

    <code>
    public DataType createDataType(int sqlType, String sqlTypeName)
    </code>

Regards,
matthias


> -----Ursprüngliche Nachricht-----
> Von: "Jeremy Whiting" <[hidden email]>
> Gesendet: 22.10.09 13:23:18
> An: <[hidden email]>
> Betreff: Re: [dbunit-user] Data type factory for Derby database.


>
> Hello Matthias,
>   Yes I am getting an error. I have a flat XML data set for a sample application. This is being loaded before some integration tests.
>  The table record XML data contains a Boolean value for the column "IS_ADMIN".
>  When DBUnit attempts to load the record into the database it barfs an exception.
>  
> This is the offending xml snipet
>
> *************
>     <USERS
>         USER_ID             ="1"
>         OBJ_VERSION         ="0"
>         FIRSTNAME           ="John"
>         LASTNAME            ="Doe"
>         USERNAME            ="johndoe"
>         PASSWORD            ="secret"
>         EMAIL               ="[hidden email]"
>         RANK                ="0"
>         IS_ADMIN            ="TRUE"
>         CREATED             ="2006-09-23 13:45:00"
>         HOME_STREET         ="Foostreet"
>         HOME_ZIPCODE        ="22222"
>         HOME_CITY           ="Foocity"
>         DEFAULT_BILLING_DETAILS_ID ="[NULL]"
>     />
>
> *************
>
> and this is the exception
>
> *************
>    [testng] Failed to invoke @Configuration method auction.test.EJB3IntegrationTest.beforeTestMethod:Error casting value for table 'USERS' and column 'IS_ADMIN'
>    [testng] FAILED: beforeTestMethod
>    [testng] org.dbunit.dataset.datatype.TypeCastException: Error casting value for table 'USERS' and column 'IS_ADMIN'
>    [testng]     at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:190)
>    [testng]     at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
>    [testng]     at auction.test.EJB3IntegrationTest.beforeTestMethod(Unknown Source)
>    [testng] Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value <true> of type <java.lang.String> to SMALLINT
>    [testng]     at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:81)
>    [testng]     at org.dbunit.dataset.datatype.IntegerDataType.setSqlValue(IntegerDataType.java:106)
>    [testng]     at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:73)
>    [testng]     at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:63)
>    [testng]     at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:186)
>    [testng]     ... 25 more
>    [testng] Caused by: java.lang.NumberFormatException
>    [testng]     at java.math.BigDecimal.<init>(BigDecimal.java:455)
>    [testng]     at java.math.BigDecimal.<init>(BigDecimal.java:724)
>    [testng]     at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:77)
>    [testng]     ... 29 more
>    [testng] ... Removed 23 stack frames
>
> *************
>
>  I have not looked at the dbunit code. Is there an interceptor chain to handle the type mappings ?
>
> Thanks,
> Jeremy
>
>
>
> Jeremy R. Whiting, Mobile: 07968722015, MSN: [hidden email], Skype: whitingjr
>
>
>      
> _________________________________________________________________
> Chat to your friends for free on selected mobiles
> http://clk.atdmt.com/UKM/go/174426567/direct/01/
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>


______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user