Java – reset auto increment in H2
•
Java
I'm testing a controller that returns a JSON response but doesn't
@Before public void setUp() { Fixtures.deleteAllModels(); Fixtures.loadModels("data.yaml"); }
How to solve this problem?
Solution
Start your playback app and use this URL to start the browser (if you run the playback app locally):
http://localhost:9000/@db
Enter your H2 dB, then enter the following command and run it:
ALTER TABLE <table_name> ALTER COLUMN <column_name> RESTART WITH 1
If you want to do this programmatically, fixtures Executesql () can be useful
For more information, see http://www.h2database.com/html/grammar.html#alter_table_alter
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码