I use an in memory Derby database with Hibernate to create the tables. My tests use dbunit to prepare the database with test data.
db.driverClass=org.apache.derby.jdbc.EmbeddedDriver
db.url=jdbc:derby:memory:myDb;c开发者_如何学编程reate=true
hibernate.dialect=org.hibernate.dialect.DerbyDialect
hibernate.hbm2ddl.auto=create-drop
Hibernate seems to create a smallint column type to store a boolean value. But dbunit cannot convert this value.
Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value <true> of type <java.lang.String> to SMALLINT
Any idea to make Hibernate create a boolean column (if available in derby) or to make dbunit write java boolean to the smallint column?
This explains the same issue, but there seems to be no DataTypeFactory implementation for Derby. http://old.nabble.com/Data-type-factory-for-Derby-database.-td25996976.html
I don't believe a true boolean datatype is currently available in Derby, although there is work underway to provide one, see: https://issues.apache.org/jira/browse/DERBY-4716. A Derby release supporting that work is expected "soon".
精彩评论