-2

We have a table invoice_meta_data which is partitioned into

  1. invoice_meta_data_10m
  2. invoice_meta_data_20m

Now when I try to delete the data using DatabaseOperation.DELETE.execute(connection, invoiceDataSet);

    at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:305) ~[dbunit-2.7.3.jar:?]
    at org.dbunit.operation.AbstractOperation.getOperationMetaData(AbstractOperation.java:80) ~[dbunit-2.7.3.jar:?]
    at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:151) ~[dbunit-2.7.3.jar:?]
    at domain.dsinvoicing.common.db.InvoiceDbHook.insertData(InvoiceDbHook.java:95) [test-classes/:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_271]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_271]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_271]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_271]
    at io.cucumber.java.Invoker.invoke(Invoker.java:27) [cucumber-java-5.7.0.jar:?]
    at io.cucumber.java.JavaHookDefinition.execute(JavaHookDefinition.java:61) [cucumber-java-5.7.0.jar:?]
    at io.cucumber.core.runner.CoreHookDefinition.execute(CoreHookDefinition.java:31) [cucumber-core-5.7.0.jar:?]
    at io.cucumber.core.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:20) [cucumber-core-5.7.0.jar:?]
    at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:64) [cucumber-core-5.7.0.jar:?]

DBunit configuration is

  IDatabaseConnection connection = new DatabaseConnection(conn,schema);
  DatabaseConfig dbConfig = connection.getConfig();
  dbConfig.setProperty(DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES, false);
  dbConfig .setProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER, new
  DefaultMetadataHandler());
  dbConfig.setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, Boolean.TRUE);
  dbConfig.setProperty(DatabaseConfig.PROPERTY_TABLE_TYPE, new String[] { "VIEW", "TABLE" });
  dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new JsonbDataFactory());

So basically how to handle the partitions in DBubit

sadath pasha
  • 49
  • 11

2 Answers2

0

Adding all the postgress table types solved the issue.

sadath pasha
  • 49
  • 11
0

dbunit before executing query verify if the table name exists. If fails to retrieve partitioned tables since in postgres the table type for partitioned tables is 'PARTITIONED TABLE' . By default dbunit retrieves all tables with table type 'TABLE' which retrieves all the tables partitions without the original tables.

where the connection to the dbunit being generated, external configuration must be made.

connection.getConfig.setProperty(DatabaseConfig.PROPERTY_TABLE_TYPE, Array[String]("VIEW", "TABLE", "PARTITIONED TABLE"))

where connection is dbunit DatabaseConnection