We have a user-defined database type (that is essentially an enum). When using any version of the JDBC driver, we can insert into that database field with our normal operational code (which only does single inserts).
However, when using DBUnit with our test code, it performs a batch insert into our test database for initialization of a test. In order to get this to initially work with our user-defined type (back a couple of years ago), we added a class that extends "org.dbunit.ext.postgresql.PostgresqlDataTypeFactory" and overrides the method "isEnumType". This was all that was needed to handle the user-defined type.
But now with upgrading versions of the postgres JDBC driver, it does not work. With changing only the JDBC driver, it breaks when moving from version 9.2 to 9.3.
These versions work: 9.2-1004-jdbc4, 9.2-1004-jdbc41
These versions do NOT work: 9.3-1100-jdbc4, 9.3-1100-jdbc41, 9.4-1201-jdbc41
Any ideas on how to resolve this? Stack trace:
[junit] Caused by: org.dbunit.DatabaseUnitException: Exception processing table name='FOO'
[junit] at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:231)
[junit] at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
[junit] at org.unitils.dbunit.datasetloadstrategy.impl.CleanInsertLoadStrategy.doExecute(CleanInsertLoadStrategy.java:45)
[junit] at org.unitils.dbunit.datasetloadstrategy.impl.BaseDataSetLoadStrategy.execute(BaseDataSetLoadStrategy.java:44)
[junit] ... 51 more
[junit] Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into "public"."FOO" ("fooid", "name", "desc", "parentfooid", "gtype") values (999999, 'Virtual', 'Virtual Machines', 0, 'virtual') was aborted. Call getNextException to see the cause.
[junit] at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2762)
[junit] at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1999)
[junit] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:421)
[junit] at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2929)
[junit] at org.dbunit.database.statement.PreparedBatchStatement.executeBatch(PreparedBatchStatement.java:86)
[junit] at org.dbunit.database.statement.AutomaticPreparedBatchStatement.executeBatch(AutomaticPreparedBatchStatement.java:83)
[junit] at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:224)
[junit] ... 54 more
The offending column is "gtype" (and the batch insert works if I remove setting this column). "gtype" is defined as follows:
Column | Type | Modifiers
---------+---------+--------------------------
gtype | vtype | default 'regular'::vtype
Schema | Name | Internal name | Size | Elements | Access privileges | Description
--------+-------+---------------+------+-------------+-------------------+-------------
public | vtype | vtype | 4 | regular +| |
| | | | location +| |
| | | | restriction+| |
| | | | virtual | |