0

I have developed Spring boot application. I wanna to do integration test with h2 database. I want some real time data to test. One high level entity contains lot of "one-to-many" and "one-to-one" entity. I need to write 25 queries to get actual data in sql developer.

I need lot of test data. Is there any way to export hibernate objects into DML (insert) statements

1
  • 1
    What do you mean by "export hibernate objects into DML". You could simply do an export of the data of your database and adjust this data to your needs. Commented Apr 13, 2019 at 9:10

2 Answers 2

1

Both MySQL Workbench and DBeaver have a feature to generate DML and DDL statements from tables. But only DBeaver has an option to also generate mock data, take a look here.

So, if you are using MySQL Workbench, you can extract the INSERT statements and then create some data yourself, or you could simple try an online mock data generators like this one.

Sign up to request clarification or add additional context in comments.

Comments

0

I think it is better to write a fixture for the test environment. I do it several times special when I need to get performance tests so I have to init my DB to have more than 10 million records.

@Service
public class DevFixture extends BaseService implements CommandLineRunner {

......

 @Override
 public void run(){
 if(isTestEnvironment())
  for (int i = 0; i < 2000000; i++)
            xxxService.add(
                    (byte) (i % 2),(byte) (i % 3),"yyyy" + i,
                     reservationId);
  }       
}

Although In advanced ways, there are a bunch of data generator tools and methods, this way maybe can resolve your problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.