|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
NoSuchColumnException on Oracle for NUMBER(10, 0) fieldHi list,
I've been trying to integrate DbUnit into the unit tests for my project today. I'm using JUnit 4 with a Spring test-runner, and first I'd like to say that all DbUnit exceptions get swallowed somewhere along the way and the only way to find the cause of an exception is to debug deep into the source. Now, most of my data gets inserted, however, I receive a "NoSuchColumnException: covenantees.company_id" near the end of the data insertion phase. The field in question "company_id" is present in the table, it's datatype is NUMBER(10,0) - as are my primary keys and a lot of other foreign keys that have been referenced to without problems in prior INSERTs. I've set the schema name on the IDatabaseTester and have already tried setting a custom IDataTypeFactory on the connection but that doesn't seem to help. Running the generated SQL on the database manually works, too. Searching the list archives, I could not come up with another solution than using a custom IDataTypeFactory. I'd be grateful for any hints. Best regards Marcus P.S.: My code and configuration: [code] @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/SpringConfig.xml" }) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) @Transactional public class CopyrightSettlementServiceImplTest { @Resource private IDatabaseTester databaseTester; @Before public void setUp() throws Exception { databaseTester.getConnection().getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new OracleDataTypeFactory()); IDataSet[] dataSets = { new FlatXmlDataSet(CopyrightSettlementServiceImplTest.class.getClassLoader().getResource("fixtures/copyrights.xml")), new FlatXmlDataSet(CopyrightSettlementServiceImplTest.class.getClassLoader().getResource("fixtures/covenantees.xml")) }; IDataSet dataSet = new CompositeDataSet(dataSets); databaseTester.setDataSet(dataSet); databaseTester.onSetup(); } } [/code] [sql] SQL> desc covenantees; Name Null? Type ----------------------------------------- -------- ---------------------------- ID NUMBER(38) [...] COMPANY_ID NUMBER(38) [...] [/sql] [springConfig] <bean id="defaultSetupOperation" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"> <property name="staticField" value="org.dbunit.operation.DatabaseOperation.CLEAN_INSERT" /> </bean> <bean id="databaseTester" class="org.dbunit.DataSourceDatabaseTester"> <constructor-arg ref="dataSource" /> <property name="setUpOperation" ref="defaultSetupOperation"/> <property name="schema"><value>APP_TESTING</value></property> </bean> [/springConfig] ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ dbunit-user mailing list dbunit-user@... https://lists.sourceforge.net/lists/listinfo/dbunit-user |
|
|
Re: NoSuchColumnException on Oracle for NUMBER(10, 0) fieldHi Marcus,
I'll answer the swallowed exception part only: I hope the release coming out in a few minutes will solve at least this part. 2008/5/5 Marcus Ilgner <marcus.ilgner@...>: > Hi list, > > I've been trying to integrate DbUnit into the unit tests for my > project today. I'm using JUnit 4 with a Spring test-runner, and first > I'd like to say that all DbUnit exceptions get swallowed somewhere > along the way and the only way to find the cause of an exception is to > debug deep into the source. > Now, most of my data gets inserted, however, I receive a > "NoSuchColumnException: covenantees.company_id" near the end of the > data insertion phase. > The field in question "company_id" is present in the table, it's > datatype is NUMBER(10,0) - as are my primary keys and a lot of other > foreign keys that have been referenced to without problems in prior > INSERTs. > I've set the schema name on the IDatabaseTester and have already tried > setting a custom IDataTypeFactory on the connection but that doesn't > seem to help. Running the generated SQL on the database manually > works, too. > Searching the list archives, I could not come up with another solution > than using a custom IDataTypeFactory. > I'd be grateful for any hints. > > Best regards > Marcus > > P.S.: My code and configuration: > > [code] > @RunWith(SpringJUnit4ClassRunner.class) > @ContextConfiguration(locations = { "/SpringConfig.xml" }) > @TransactionConfiguration(transactionManager = "transactionManager", > defaultRollback = true) > @Transactional > public class CopyrightSettlementServiceImplTest { > > @Resource > private IDatabaseTester databaseTester; > > @Before > public void setUp() throws Exception { > databaseTester.getConnection().getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, > new OracleDataTypeFactory()); > IDataSet[] dataSets = { new > FlatXmlDataSet(CopyrightSettlementServiceImplTest.class.getClassLoader().getResource("fixtures/copyrights.xml")), > new FlatXmlDataSet(CopyrightSettlementServiceImplTest.class.getClassLoader().getResource("fixtures/covenantees.xml")) > }; > IDataSet dataSet = new CompositeDataSet(dataSets); > databaseTester.setDataSet(dataSet); > databaseTester.onSetup(); > } > } > [/code] > > [sql] > SQL> desc covenantees; > Name Null? Type > ----------------------------------------- -------- ---------------------------- > ID NUMBER(38) > [...] > COMPANY_ID NUMBER(38) > [...] > [/sql] > > [springConfig] > <bean id="defaultSetupOperation" > class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"> > <property name="staticField" > value="org.dbunit.operation.DatabaseOperation.CLEAN_INSERT" /> > </bean> > > <bean id="databaseTester" class="org.dbunit.DataSourceDatabaseTester"> > <constructor-arg ref="dataSource" /> > <property name="setUpOperation" ref="defaultSetupOperation"/> > <property name="schema"><value>APP_TESTING</value></property> > </bean> > [/springConfig] > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > dbunit-user mailing list > dbunit-user@... > https://lists.sourceforge.net/lists/listinfo/dbunit-user > -- Roberto Lo Giacco ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ dbunit-user mailing list dbunit-user@... https://lists.sourceforge.net/lists/listinfo/dbunit-user |
| Free Forum Powered by Nabble | Forum Help |