【发布时间】:2015-08-07 20:46:22
【问题描述】:
我正在运行 dbunit 2.4.9。切换到新的 oracle 实例后,我得到了 AmbiguousTableNameException。 doc 表示我应该在创建连接时将模式名称放入连接中。但我不能覆盖 DBTestCase 上的 getConnection,因为它是最终的。我应该选择不同的超类吗?我是否忽略了什么?
这是我的测试用例类。
public abstract class DbTestCase extends DBTestCase
{
private static boolean doOnce = false;
private Session session;
public DbTestCase() throws Exception
{
super();
System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, "oracle.jdbc.driver.OracleDriver" );
System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, "jdbc:oracle:thin:@host:1521:sid" );
System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, "id" );
System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, "xxxx_15" );
}
@Override
protected void setUp() throws Exception
{
super.setUp();
if(!doOnce){
doOnce = true;
BasicConfigurator.configure();
MyHibernateFactory.initilize();
}
session = MyHibernateFactory.getSession();
session.beginTransaction();
}
public void tearDown() throws Exception
{
...
}
@Override
protected IDataSet getDataSet() throws Exception
{
return new FlatXmlDataSetBuilder().build(new FileInputStream("src/dbtest/dataset.xml"));
}
}
【问题讨论】: