4

I have this project that I ran in Jhipster with the generator yo jhipster:import-jdl. When it ends, everything is clean and ready to start. This is the state I would like to easily return to, in the H2 persistent disk copy, when I do tests, changes and so on, to start all over again.

I guess that using H2 non-persistent memory would create everything every time I start the project, but is there any easy way to get that result in a disk persistent type? (Please confirm)

Or, better, is there a way to tell Jhipter to change from a memory to a persistent database to a memory persistence, at will, before you yarn start the project?

If there is no way to change this at will, I googled for a solution and it looks like I should DROP ALL OBJECTS Reset Embedded H2 database periodically and then I do not know what to do to get to a clean database.

Mohsen
  • 4,536
  • 2
  • 27
  • 49
Mike
  • 1,059
  • 5
  • 28
  • 51

2 Answers2

9

When you use a H2 disk database, the files related to your database is in target/h2db/db/ folder, with *.db extension.

To get a clean H2 database, you simply need to launch ./mvnw clean, so it will delete the target folder.

Pascal Grimaud
  • 1,161
  • 1
  • 8
  • 9
  • is there a way to tell Jhipter to change from a memory to a persistent database to a memory persistence, at will, before you yarn start the project? Thanks Pascal – Mike Jun 13 '18 at 13:08
  • The changes required to go from disk->memory are small, but there is no automated way to do it. Here's an example for an app with `h2switch` as the base name https://github.com/ruddell/jhipster-examples/commit/e2a5db6ecc3aada0de7519519c3376d4134fe3cd – Jon Ruddell Jun 13 '18 at 15:01
0

To clean H2 database in maven:

./mvnw clean

And In gradle:

./gradlew clean
Mohsen
  • 4,536
  • 2
  • 27
  • 49