Hello, I have a problem with sequences manage in H2 database. This is my problem: - The application uses an H2 database with auto commit - When starting the server, a DataSource (JdbcConnectionPool in my case for h2) is created - When the first connection is done for the first query (call getConnection() on DataSource), a call to org.h2.engine.Database.openDatabase() is done (a ".lock.db" file is created) - For INSERT queries, a sequence is used for the ID column (because of AUTO_INCREMENT) - All connections are well closed after queries execution - When stopping the server, a call to JdbcConnectionPool.dispose() is done = call to org.h2.engine.Database.close() (the ".lock.db" file is deleted). In that case, the sequence value is well persist in database. - When the server is killed (the client need to kill it is some case so we have to be robust), no call to JdbcConnectionPool.dispose() and org.h2.engine.Database.close() is done (because the process is killed). The sequence value is not persisted and is re-initialized (so there is an inconsistency between data in table and the sequence which has been re-initialized). The result is that when an INSERT is done after re-starting the server, an SQLException happens for a primary key violation. I thought the problem was caused by the cache for sequences so I tried to create a sequence manually and deactivate the cache for it but the problem is still present. Is there a developer of the h2 project who can explain me why, when the connection is not well closed by the DataSource, the value of the sequence is not persist in base when the cache is deactivated? Is there someone who can help me with that problem please?
-- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
