dbunit

How to extract a subset of a database into a dbunit file using a sql query?

放肆的年华 提交于 2020-01-03 18:37:59
问题 Why ? I have got a big Oracle table. I would like to test some DAO methods. To do so, I use dbunit. Problem I would like to extract a subset of an existing database as a dbunit flat xml file using a sql query. Example of query : Select t1.field1 as field1, t1.field2 as field2, t2.field3 as field3 From table1 t1 Join table2 t2 on t1.fieldX=t2.fieldX Where t1.field6='value' and t2.field8='value2' in this case it will extract all records of table1 and table2 which are results of the query and

How to extract a subset of a database into a dbunit file using a sql query?

守給你的承諾、 提交于 2020-01-03 18:37:46
问题 Why ? I have got a big Oracle table. I would like to test some DAO methods. To do so, I use dbunit. Problem I would like to extract a subset of an existing database as a dbunit flat xml file using a sql query. Example of query : Select t1.field1 as field1, t1.field2 as field2, t2.field3 as field3 From table1 t1 Join table2 t2 on t1.fieldX=t2.fieldX Where t1.field6='value' and t2.field8='value2' in this case it will extract all records of table1 and table2 which are results of the query and

Spring Test DBUnit and table schema name

痞子三分冷 提交于 2020-01-02 05:30:28
问题 Is it possible to set the table schema name when using @DatabaseSetup annotation from Spring Test DBUnit? Currently I'm using it like this: @DatabaseSetup("user-data.xml") public class UserMapperTest { } user-data.xml: (I also tried to set the element name to user.system_user without any luck) <dataset> <system_user ... /> </dataset> And here I'm creating my table with schema called user: create table "user".system_user (...); And this is the exception that I get when running test: org.h2

Expoting Dataset to a xml file giving error in DBunit

被刻印的时光 ゝ 提交于 2019-12-31 03:51:12
问题 Hi all i'm working using dbunit. I'm trying to export datset of db into a xml file. import java.sql.Connection; import java.sql.DriverManager; import org.dbunit.database.DatabaseConnection; import org.dbunit.database.IDatabaseConnection; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.xml.FlatXmlDataSet; import java.io.FileOutputStream; public class DatabaseExport { public static void main(String[] args) throws Exception { Class.forName("com.microsoft.sqlserver.jdbc

Persistence.createEntityManagerFactory takes ages

柔情痞子 提交于 2019-12-25 01:48:31
问题 I have a DBUnit test which runs OK, but is taking ages (4-5 mins) to create the entity manager factory. I am using JPA with hibernate and SQL serve. Would be of great help if anybody could throw some light on this. My machine seems faster to blame it on Sql server :) Here is my setup code. @BeforeClass public static void initEntityManager() throws Exception { emf = Persistence.createEntityManagerFactory("primary"); em = emf.createEntityManager(); tx = em.getTransaction(); connection = new

Converting between oracle.sql.TIMESTAMPTZ and standard JDBC classes for DbUnit

邮差的信 提交于 2019-12-24 07:58:30
问题 I'm running Oracle 10g and have columns with Type_Name TIMESTAMP(6) WITH TIME ZONE When inflated into java classes they come out as oracle.sql.TIMESTAMPTZ But DbUnit can't handle converting Oracle specific classes to Strings for writing to XML. I'm wondering if there's any easy way for me to convert (say, in my SELECT statement somehow) from these Oracle specific timestamps to something in java.sql. 回答1: I haven't had to deal with this problem exactly, but I presume that having it come

Converting between oracle.sql.TIMESTAMPTZ and standard JDBC classes for DbUnit

夙愿已清 提交于 2019-12-24 07:57:58
问题 I'm running Oracle 10g and have columns with Type_Name TIMESTAMP(6) WITH TIME ZONE When inflated into java classes they come out as oracle.sql.TIMESTAMPTZ But DbUnit can't handle converting Oracle specific classes to Strings for writing to XML. I'm wondering if there's any easy way for me to convert (say, in my SELECT statement somehow) from these Oracle specific timestamps to something in java.sql. 回答1: I haven't had to deal with this problem exactly, but I presume that having it come

Hibernate : Sorting ManyToMany mapping

天涯浪子 提交于 2019-12-23 18:13:22
问题 Consider the following mapping with JPA annotations @ManyToMany(cascade = { CascadeType.ALL }) @JoinTable(name = "infotype_validations", joinColumns = { @JoinColumn(name = "info_type_id") }, inverseJoinColumns = { @JoinColumn(name = "validation_id") } ) @OrderBy(value="validation_id desc") public Set<Validation> getValidation() { return validation; } My intention is to have a jointable in the database and each time the getValidation() is called in my services the records get returned ordered

database restore to particular state for testing

主宰稳场 提交于 2019-12-23 01:12:29
问题 We use an Oracle(or postgres) database and an application server to execute integration tests. To isolate each test from another one , the database schema is dropped and re-created before each test. As you see this is a time taking process. The application uses 100+ tables. We are thinking of writing custom sql to delete unwanted data from each tables. Is there a better way to save and restore database state? ( It appears DBUnit could do this, I have not tried it yet. ) A single test involves

DBUnit Sybase unable to CLEAN_INSERT

試著忘記壹切 提交于 2019-12-22 18:45:45
问题 According to the DBUnit docs link it should support using a CLEAN_INSERT when using a DatabaseSequenceFilter. I get the following exception when attempting this com.sybase.jdbc2.jdbc.SybSQLException: Dependent foreign key constraint violation in a referential integrity constraint. dbname = 'my_db', table name = 'tbl_child', constraint name = 'fk_tbl_child_parentid'. My tables look like this: CREATE TABLE dbo.tbl_parent ( parent_id numeric(19,0) IDENTITY, ... ) CREATE TABLE dbo.tbl_child (