-
-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Javers doesn't work properly with H2 2.0.204 version (Invalid SQL syntax for the Sequence) #1168
Labels
Comments
@pziobron sorry but I cant help you if you do not provide a failing test case. This is an OSS project. |
jamesmudd
added a commit
to jamesmudd/javers
that referenced
this issue
Apr 5, 2022
This reproduces the bug in javers#1168 by updating H2 to 2.1.210 which is good any was as earlier versions have known exploits https://mvnrepository.com/artifact/com.h2database/h2. As recommended in H2 migration to v2 docs http://www.h2database.com/html/migration-to-v2.html this switches to sequence value expression https://h2database.com/html/grammar.html#sequence_value_expression This is backwards compatible with H2 v1
jamesmudd
added a commit
to jamesmudd/javers
that referenced
this issue
May 24, 2022
This reproduces the bug in javers#1168 by updating H2 to 2.1.210 which is good any was as earlier versions have known exploits https://mvnrepository.com/artifact/com.h2database/h2.
bartoszwalacik
added
fixed - waiting to be released
fixed
and removed
test case required
fixed - waiting to be released
labels
Dec 25, 2022
fixed in 6.8.1 |
bartoszwalacik
pushed a commit
that referenced
this issue
Jul 16, 2023
This reproduces the bug in #1168 by updating H2 to 2.1.210 which is good any was as earlier versions have known exploits https://mvnrepository.com/artifact/com.h2database/h2.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Javers doesn't work properly with H2 2.0.204 version (Invalid SQL syntax for the Sequence)
Steps To Reproduce
Try to use Javers with the newest H2 (2.0.204) dependency.
Unfortunately, I do not have time to write a runnable test.
You will observe the following error:
com.hsbc.gecs.dtcswebapp.application.rest.advice.CustomResponseEntityExceptionHandler: The following Exception occured: org.javers.common.exception.JaversException: SQL_EXCEPTION: Column "JV_COMMIT_PK_SEQ.NEXTVAL" not found; SQL statement: SELECT jv_commit_pk_seq.nextval [42122-204] while executing sql: SELECT jv_commit_pk_seq.nextval at org.javers.repository.sql.session.PreparedStatementExecutor.wrapExceptionAndCall(PreparedStatementExecutor.java:128) at org.javers.repository.sql.session.PreparedStatementExecutor.<init>(PreparedStatementExecutor.java:27) at org.javers.repository.sql.session.Session.getOrCreatePreparedStatement(Session.java:120) at org.javers.repository.sql.session.Session.executeQueryForLong(Session.java:85) at org.javers.repository.sql.session.Sequence.nextValue(Sequence.java:27) at org.javers.repository.sql.session.KeyGenerator$SequenceAllocation.generateKey(KeyGenerator.java:42) at org.javers.repository.sql.session.Session.executeInsertAndGetSequence(Session.java:46) at org.javers.repository.sql.session.InsertBuilder.executeAndGetSequence(InsertBuilder.java:54) at org.javers.repository.sql.repositories.CommitMetadataRepository.save(CommitMetadataRepository.java:35) at org.javers.repository.sql.JaversSqlRepository.persist(JaversSqlRepository.java:86) at org.javers.repository.api.JaversExtendedRepository.persist(JaversExtendedRepository.java:154) at org.javers.core.JaversCore.persist(JaversCore.java:109) at org.javers.core.JaversCore.commit(JaversCore.java:90) at org.javers.spring.transactions.JaversTransactionalDecorator.commit(JaversTransactionalDecorator.java:68) at org.javers.spring.jpa.JaversTransactionalJpaDecorator.commit(JaversTransactionalJpaDecorator.java:50) at org.javers.spring.jpa.JaversTransactionalJpaDecorator$$FastClassBySpringCGLIB$$8b0feaeb.invoke(<generated>)
Javers' Version
6.5.3
Additional context
I've tested the fix and it works (JaversException is not raised any more) !
Modify the body of the getKeyGeneratorDefinition method in the H2 inner static class of the org.javers.repository.sql.session.Dialects class (in the javers-persistence-sql package) by replacing
this line:
return (SequenceDefinition) seqName -> seqName + ".nextval";
with:
return (SequenceDefinition) seqName -> "NEXT VALUE FOR " + seqName;
The text was updated successfully, but these errors were encountered: