I have a Spring project using Hibernate. The DB is generated based on the models and their annotations. For testing purposes, I would like to set up a in-memory DB.
@Before
public void setUp() {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2).addScript("???").build();
}
How can I get the script that is generated by Hibernate programatically?
Do you mean
hbm2ddlfeature of Hibernate? You don’t have to pass the script explicitly. If this feature is enabled, Hibernate will automatically run the script on a providedDataSource(EmbeddedDatabaseactually implementsDataSource). No manual work needed.