I'm trying to import the data and tables from a XML file to an in-memory database, which XML file I create automatically using DBUnit. Here are two of the classes I'm mapping: WorkbookMapping:
@Entity(name="Workbook")
public class WorkbookMapping implements Serializable {
@Id
@GeneratedValue
private int id;
@OneToMany(cascade = CascadeType.ALL )
List<SpreadSheetMapping> list = new ArrayList<SpreadSheetMapping>();
public WorkbookMapping() {
}
public WorkbookMapping(Workbook workbook) {
for (int i = 0; i < workbook.getSpreadsheetCount(); i++) {
list.add(new SpreadSheetMapping(workbook.getSpreadsheet(i)));
}
}
}
SpreadSheetMapping:
@Entity(name="Spreadsheet")
public class SpreadSheetMapping implements Serializable {
@Id
@GeneratedValue
private long id;
@OneToMany(cascade = CascadeType.ALL)
List<CellMapping> list;
public SpreadSheetMapping() {
}
public SpreadSheetMapping(Spreadsheet sp) {
list = new ArrayList<CellMapping>();
for (int r = 0; r < sp.getRowCount(); r++) {
for (int i = 0; i < sp.getColumnCount(); i++) {
list.add(new CellMapping(sp.getCell(i, r)));
}
}
}
}
Here is my hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hbm2ddl.auto">update</property>
<property name="hibernate.show_sql">true</property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:mem:DBMemoria</property>
<property name="connection.username"/>
<property name="connection.password"/>
<property name="connection.pool_size">1</property>
<mapping class="csheets.io.WorkbookMapping"/>
<mapping class="csheets.io.SpreadSheetMapping"/>
<mapping class="csheets.io.CellMapping"/>
</session-factory>
</hibernate-configuration>
And this is the code I'm using to import all the data to the database:
Connection jdbcConnection;
jdbcConnection = DriverManager.getConnection("jdbc:hsqldb:mem:DBMemoria", "", "");
IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
IDataSet dataSet = new XmlDataSet(stream);
DatabaseOperation.CLEAN_INSERT.execute(connection, dataSet);
And I'm getting this error:
org.dbunit.dataset.NoSuchTableException: WORKBOOK_SPREADSHEET
at org.dbunit.database.DatabaseDataSet.getTableMetaData(DatabaseDataSet.java:288)
at org.dbunit.operation.DeleteAllOperation.execute(DeleteAllOperation.java:109)
Any help?