|
From: SourceForge.net <no...@so...> - 2010-12-31 10:37:40
|
Bugs item #3148577, was opened at 2010-12-31 11:37 Message generated for change (Tracker Item Submitted) made by wyborowiec You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=449491&aid=3148577&group_id=47439 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Bug Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Waclaw Borowiec (wyborowiec) Assigned to: matthias g (gommma) Summary: MySqlDataTypeFactory saves TINYINT(1) as String Initial Comment: When writing down DB content to an XML file TINYINT(1) columns are mapped to "true" and "false" strings. DBUnit isn't however able to restore them from the XML. It throws org.dbunit.dataset.datatype.TypeCastException: Error casting value for table 't1' and column 'column1' at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:190) at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:122) at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:86) at org.junit.internal.runners.MethodRoadie.runWithTimeout(MethodRoadie.java:49) at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:40) at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51) at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37) at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value <false> of type <java.lang.String> to TINYINT at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:81) at org.dbunit.dataset.datatype.IntegerDataType.setSqlValue(IntegerDataType.java:106) at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:73) at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:63) at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:186) ... 23 more Caused by: java.lang.NumberFormatException at java.math.BigDecimal.<init>(BigDecimal.java:459) at java.math.BigDecimal.<init>(BigDecimal.java:728) at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:77) ... 27 more To fix it I created and registered data type following factory: public static class MyBetterDataTypeFactory extends MySqlDataTypeFactory { @Override public DataType createDataType(int sqlType, String sqlTypeName) throws DataTypeException { if (sqlType == Types.BIT && sqlTypeName.toLowerCase().contains("tinyint")) { return DataType.TINYINT; } DataType createDataType = super.createDataType(sqlType, sqlTypeName); return createDataType; } } and it works. It is MySQL 5.0. DBUnit 2.4.8. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=449491&aid=3148577&group_id=47439 |