Skip to content
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

Error saving new field "COMMIT_DATE_INSTANT" and creating tables on version 5.1.0 #765

Closed
NicoBondarenco opened this issue Jan 4, 2019 · 15 comments

Comments

@NicoBondarenco
Copy link

NicoBondarenco commented Jan 4, 2019

After the new version (5.1.0), when I use SQLRepository, Javers creates the new field on database like "commit_date_instant varchar(26) DEFAULT NULL" but when I try to call the commit method, I get an error saying:
"JaversException SQL_EXCEPTION: Value too long for column "COMMIT_DATE_INSTANT VARCHAR(26)": "'2019-01-04T11:36:23.572228100Z' (30)"; SQL statement:
INSERT INTO jv_commit ( author, commit_date, commit_date_instant, commit_id, commit_pk ) VALUES ( ?,?,?,?,? ) [22001-197]
while executing sql: INSERT INTO jv_commit ( author, commit_date, commit_date_instant, commit_id, commit_pk ) VALUES ( ?,?,?,?,? )"

Looking in the code, I saw that the "COMMIT_DATE_INSTANT" value is formatted to a String using "DateTimeFormatter.ISO_INSTANT.format(dateInstant)" (org.javers.repository.sql.repositories.CommitMetadataRepository:40). This is generating a String(30).

Is it possible to leave this "DateTimeFormatter.ISO_INSTANT" as a default and create a configuration to format this field? Or alter the column generation to a larger length?

BTW: I'm using Javers with H2 for unit tests. I also tried to use MySQL and got the same problem.

Another thing is, if I'm using Hibernate configuration "hibernate.hbm2ddl.auto" as validate and the tables are already created, Javers is trying to create the tables again on JaversBuilder.build(), then I get an error saying that the tables already exists.

@NicoBondarenco NicoBondarenco changed the title Error saving new field "COMMIT_DATE_INSTANT" on version 5.1.0 Error saving new field "COMMIT_DATE_INSTANT" and creating tables on version 5.1.0 Jan 4, 2019
@bartoszwalacik
Copy link
Member

thanks for reporting, we will fix it

@bartoszwalacik
Copy link
Member

did you do something special to build Instant with nano precision?
on my machine it looks like:

        def now = Instant.now()
        println "now: " + now

        now: 2019-01-04T16:19:27.463Z

Which java version and vendor do you have?

@NicoBondarenco
Copy link
Author

NicoBondarenco commented Jan 4, 2019

My Java version is
java 10.0.2 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

I don't know if could be it, but maybe the region? I'm from Brazil.

I tried to use a custom provider too, and got the same problem. (.withDateTimeProvider(() -> ZonedDateTime.now(ZoneOffset.UTC)))

jshell> ZonedDateTime.now()
$2 ==> 2019-01-04T14:29:27.824778400-02:00[America/Sao_Paulo]

jshell> ZonedDateTime.now().toInstant()
$3 ==> 2019-01-04T16:29:51.205005500Z

jshell> Instant.now()
$5 ==> 2019-01-04T16:32:19.885325600Z

If it is a region problem, maybe the value should follow a custom pattern to avoid these kind of problem, so if I save in one region and read in another, I won't have any problems.

@bartoszwalacik
Copy link
Member

looks like java 10 creates Instant.now() with nano precision while java 8 creats with millis precision. I will fix it

bartoszwalacik added a commit that referenced this issue Jan 4, 2019
@bartoszwalacik
Copy link
Member

fixed in 5.1.1
check it out

@NicoBondarenco
Copy link
Author

Thanks very much

@NicoBondarenco
Copy link
Author

NicoBondarenco commented Jan 5, 2019

Still getting the same error in version 5.1.1, and I'm getting some other errors too.

  1. The first stacktrace is the same error.
  2. The second error is when I try to use only QueryBuilder.from, only QueryBuilder.to and both.
  3. The third is when I already have the Javers tables created and start the application again, or when I create the tables in H2 before the tests and then instantiate Javers.

`JaversException SQL_EXCEPTION: Value too long for column "COMMIT_DATE_INSTANT VARCHAR(26)": "'2019-01-05T21:31:38.881609100Z' (30)"; SQL statement:
INSERT INTO jv_commit ( author, commit_date, commit_date_instant, commit_id, commit_pk ) VALUES ( ?,?,?,?,? ) [22001-197]
while executing sql: INSERT INTO jv_commit ( author, commit_date, commit_date_instant, commit_id, commit_pk ) VALUES ( ?,?,?,?,? )

at org.javers.repository.sql.session.PreparedStatementExecutor.wrapExceptionAndCall(PreparedStatementExecutor.java:120)
at org.javers.repository.sql.session.PreparedStatementExecutor.runVoidSql(PreparedStatementExecutor.java:110)
at org.javers.repository.sql.session.PreparedStatementExecutor.execute(PreparedStatementExecutor.java:39)
at org.javers.repository.sql.session.Session.execute(Session.java:104)
at org.javers.repository.sql.session.Session.executeInsertAndGetSequence(Session.java:51)
at org.javers.repository.sql.session.InsertBuilder.executeAndGetSequence(InsertBuilder.java:54)
at org.javers.repository.sql.repositories.CommitMetadataRepository.save(CommitMetadataRepository.java:43)
at org.javers.repository.sql.JaversSqlRepository.persist(JaversSqlRepository.java:89)
at org.javers.repository.api.JaversExtendedRepository.persist(JaversExtendedRepository.java:154)
at org.javers.core.JaversCore.persist(JaversCore.java:104)
at org.javers.core.JaversCore.commit(JaversCore.java:85)
at com.raise.base.repository.BaseRepository.auditEntity(BaseRepository.java:220)
at com.raise.base.repository.BaseRepository.save(BaseRepository.java:107)
at com.raise.base.repository.BaseRepositoryTest.testInsert(BaseRepositoryTest.java:139)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:532)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:171)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:167)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:114)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:59)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:108)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)`

`java.lang.NullPointerException: text

at java.base/java.util.Objects.requireNonNull(Objects.java:246)
at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1945)
at java.base/java.time.Instant.parse(Instant.java:395)
at org.javers.core.json.CdoSnapshotSerialized.withCommitDateInstant(CdoSnapshotSerialized.java:45)
at org.javers.repository.sql.finders.SnapshotQuery$CdoSnapshotMapper.get(SnapshotQuery.java:166)
at org.javers.repository.sql.finders.SnapshotQuery$CdoSnapshotMapper.get(SnapshotQuery.java:160)
at org.javers.repository.sql.session.PreparedStatementExecutor.lambda$executeQuery$5(PreparedStatementExecutor.java:64)
at org.javers.repository.sql.session.PreparedStatementExecutor.wrapExceptionAndCall(PreparedStatementExecutor.java:126)
at org.javers.repository.sql.session.PreparedStatementExecutor.runSql(PreparedStatementExecutor.java:100)
at org.javers.repository.sql.session.PreparedStatementExecutor.executeQuery(PreparedStatementExecutor.java:58)
at org.javers.repository.sql.session.Session.executeQuery(Session.java:99)
at org.javers.repository.sql.session.SelectBuilder.executeQuery(SelectBuilder.java:99)
at org.javers.repository.sql.finders.SnapshotQuery.run(SnapshotQuery.java:148)
at org.javers.repository.sql.finders.CdoSnapshotFinder.fetchCdoSnapshots(CdoSnapshotFinder.java:92)
at org.javers.repository.sql.finders.CdoSnapshotFinder.getStateHistory(CdoSnapshotFinder.java:74)
at org.javers.repository.sql.JaversSqlRepository.getStateHistory(JaversSqlRepository.java:118)
at org.javers.repository.api.JaversExtendedRepository.getStateHistory(JaversExtendedRepository.java:149)
at org.javers.repository.jql.SnapshotQueryRunner.queryForSnapshots(SnapshotQueryRunner.java:40)
at org.javers.repository.jql.ShadowQueryRunner.queryForCoreSnapshots(ShadowQueryRunner.java:78)
at org.javers.repository.jql.ShadowQueryRunner.queryForShadows(ShadowQueryRunner.java:51)
at org.javers.repository.jql.ShadowQueryRunner.queryForShadows(ShadowQueryRunner.java:47)
at org.javers.repository.jql.QueryRunner.queryForShadows(QueryRunner.java:36)
at org.javers.core.JaversCore.findShadows(JaversCore.java:183)
at com.raise.base.repository.BaseRepository.getAuditory(BaseRepository.java:191)
at com.raise.base.repository.BaseRepository.getAuditory(BaseRepository.java:153)
at com.raise.base.repository.BaseRepositoryTest.testQuantityNull(BaseRepositoryTest.java:481)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:532)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:171)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:167)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:114)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:59)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:108)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

`


`org.polyjdbc.core.exception.SchemaManagerException: [DDL_ERROR] Failed to run DDL:
CREATE TABLE jv_commit (
commit_pk BIGINT NOT NULL,
author VARCHAR(200),
commit_date TIMESTAMP,
commit_date_instant VARCHAR(26),
commit_id NUMERIC(22,2),
CONSTRAINT jv_commit_pk PRIMARY KEY(commit_pk)
)

at org.polyjdbc.core.schema.SchemaManagerImpl.ddl(SchemaManagerImpl.java:91)
at org.polyjdbc.core.schema.SchemaManagerImpl.create(SchemaManagerImpl.java:52)
at org.javers.repository.sql.schema.JaversSchemaManager.ensureTable(JaversSchemaManager.java:221)
at org.javers.repository.sql.schema.JaversSchemaManager.ensureSchema(JaversSchemaManager.java:47)
at org.javers.repository.sql.JaversSqlRepository.ensureSchema(JaversSqlRepository.java:183)
at org.javers.core.JaversBuilder.build(JaversBuilder.java:125)
at com.raise.base.repository.BaseRepositoryTest.init(BaseRepositoryTest.java:103)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:532)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$invokeBeforeAllMethods$8(ClassTestDescriptor.java:373)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeBeforeAllMethods(ClassTestDescriptor.java:372)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.before(ClassTestDescriptor.java:201)
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.before(ClassTestDescriptor.java:74)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:105)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$4(NodeTestTask.java:112)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:98)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:74)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by: org.h2.jdbc.JdbcSQLException: Table "JV_COMMIT" already exists; SQL statement:
CREATE TABLE jv_commit (
commit_pk BIGINT NOT NULL,
author VARCHAR(200),
commit_date TIMESTAMP,
commit_date_instant VARCHAR(26),
commit_id NUMERIC(22,2),
CONSTRAINT jv_commit_pk PRIMARY KEY(commit_pk)
) [42101-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.command.ddl.CreateTable.update(CreateTable.java:86)
at org.h2.command.CommandContainer.update(CommandContainer.java:102)
at org.h2.command.Command.executeUpdate(Command.java:261)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:233)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:205)
at org.polyjdbc.core.schema.SchemaManagerImpl.ddl(SchemaManagerImpl.java:88)
... 39 more

`

@bartoszwalacik
Copy link
Member

That's really strange. Looks like the root cause on your machine is still Instant serializing.

In 5.1.1, I have added the test asserting that Instants are serialized with millis precision, which gives exactly 24 chars at max.
See

def "should serialize java8.Instant to JSON using ISO format with millis, where givenValueAsSring: #givenValueAsSring"(){

it works as expected:

10:14:07.215 [main] INFO  org.javers.core.JaversBuilder - JaVers instance started in 1068 ms
serializing Instant: 2015-10-02T17:37:07Z, to:2015-10-02T17:37:07Z, len: 20
serializing Instant: 2015-10-02T17:37:07.050Z, to:2015-10-02T17:37:07.050Z, len: 24
serializing Instant: 2015-10-02T17:37:07.050228100Z, to:2015-10-02T17:37:07.050Z, len: 24

Could you set a breakpoint in debugger at InstantTypeAdapter.serialize() and check how Instants are serialized on your machine?

@bartoszwalacik bartoszwalacik reopened this Jan 6, 2019
@bartoszwalacik
Copy link
Member

and also you can easily run Javers tests on your machine:

git clone https://github.com/javers/javers.git
cd javers
./gradlew javers-core:test

@NicoBondarenco
Copy link
Author

I ran all tests in javers-core with debug and it passes correctly, but when I ran "gradlew javers-core:test" there are some errors. I'm attaching the tests results, and I'll try to do some tests here too.

nico-javers-test-result.zip

@NicoBondarenco
Copy link
Author

My problem with the insert of "COMMIT_DATE_INSTANT" seems to be in "org.javers.repository.sql.repositories.CommitMetadataRepository.save()", in this specific serialization:
image
at org.javers.repository.sql.session.PreparedStatementExecutor.wrapExceptionAndCall(PreparedStatementExecutor.java:120) at org.javers.repository.sql.session.PreparedStatementExecutor.runVoidSql(PreparedStatementExecutor.java:110) at org.javers.repository.sql.session.PreparedStatementExecutor.execute(PreparedStatementExecutor.java:39) at org.javers.repository.sql.session.Session.execute(Session.java:104) at org.javers.repository.sql.session.Session.executeInsertAndGetSequence(Session.java:51) at org.javers.repository.sql.session.InsertBuilder.executeAndGetSequence(InsertBuilder.java:54) at org.javers.repository.sql.repositories.CommitMetadataRepository.save(CommitMetadataRepository.java:43) at org.javers.repository.sql.JaversSqlRepository.persist(JaversSqlRepository.java:89) at org.javers.repository.api.JaversExtendedRepository.persist(JaversExtendedRepository.java:154) at org.javers.core.JaversCore.persist(JaversCore.java:104) at org.javers.core.JaversCore.commit(JaversCore.java:85)

@bartoszwalacik
Copy link
Member

@NicoBondarenco, nice job, thanks. This is it. Fix is on its way to Central.

@bartoszwalacik
Copy link
Member

fixed in 5.1.2

@bartoszwalacik
Copy link
Member

second fix for this issue released in 5.1.3

@JacekWislicki
Copy link

5.1.2 works correctly, still I noticed exactly the same issue with 5.1.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants