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

SQL Server 2016 schemaInspector.relationExists(tableName) Error #806

Closed
Pinellus opened this Issue Mar 15, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@Pinellus
Copy link

Pinellus commented Mar 15, 2019

Hi,
I've got a problem starting the javers app.

The first start (without javers tables) is executed without problems.

The second start goes wrong, SQL Exception because javers tries to recreate the schema for the table jv_commit (which already exists in the DB)

Going through the code, I found the error in the org.javers.repository.sql.schema.JaversSchemaManager

private void ensureTable(String tableName, Schema schema) {

        if (schemaInspector.relationExists(tableName)) {
            return;
        }
        logger.info("creating javers table {} ...", tableName);
        schemaManager.create(schema);

    }

The method ensureTable does not recognize that in the DB SQL Server the table jv_commit already exists and therefore launches again the CREATE TABLE.

This behavior is not present in version 5.0.0 of Javers (which I'm currently using to get around the problem).

Also I think that the problem is attributable to the polyjdbc library

The version of SQL Server I use is:
Microsoft SQL Server 2016 - 13.0.1708.0 (X64)
The JPA setting for the dialect is:
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect

@bartoszwalacik

This comment has been minimized.

Copy link
Member

bartoszwalacik commented Mar 15, 2019

Well, as you already know, developing on non-OSS databases is hard for us, as we don't have integration tests for it.

It would be nice to have at least local tests running on Docker and Testcontainers.
Could you help us to make this test runnable?
https://github.com/javers/javers/blob/master/javers-persistence-sql/src/test/groovy/org/javers/repository/sql/integration/mssql/MsSqlIntegrationTest.groovy

bartoszwalacik added a commit that referenced this issue Mar 17, 2019

@bartoszwalacik

This comment has been minimized.

Copy link
Member

bartoszwalacik commented Mar 17, 2019

Integration test based on docker is configured, it was easier than I thought. Looks like MS SQL Server is friendly for testing on Docker (as opposite to Oracle).

bartoszwalacik added a commit to polyjdbc/polyjdbc that referenced this issue Mar 17, 2019

javers/javers#806
Fixed bug in SchemaInspector for MS SQL Server.
Somehow, public schema is named "dbo" there.

adamdubiel added a commit to polyjdbc/polyjdbc that referenced this issue Mar 18, 2019

javers/javers#806
Fixed bug in SchemaInspector for MS SQL Server.
Somehow, public schema is named "dbo" there.

bartoszwalacik added a commit that referenced this issue Mar 20, 2019

bartoszwalacik added a commit that referenced this issue Mar 20, 2019

@bartoszwalacik

This comment has been minimized.

Copy link
Member

bartoszwalacik commented Mar 20, 2019

After applying the fix in polyJdbc, situation is much better, but still, when I run MsSqlIntegrationTest, 9 tests out of 104 fail. Further work is needed to make all tests green.

@bartoszwalacik

This comment has been minimized.

Copy link
Member

bartoszwalacik commented Mar 20, 2019

main issue with the schemaInspector is fixed in 5.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.