Hibernate comes with a nifty feature that makes it unnecessary to use DBUnit or any tool for initializing your test database with data before the unit and integration tests are run. Ofcourse you need to be using Hibernate Core or its JPA module to take advantage of this. Steps to achieve this are very straightforward
1. Configure Hibernate’s hibernate.hbm2ddl.auto property in the persistence.xml to one of the allowed values. e.g. The following configuration tells Hibernate to create the tables as per the given JPA/Hibernate mapping
<property name=”hibernate.hbm2ddl.auto” value=”create”/>
2. Place additional tables/sequences/trigger creation scripts and the test data insert statements in a file with name import.sql and place it in the runtime class path. In case of eclipse, put it directly under build/classes.
3. Make sure the insert statement has no newline character