Hibernate-reactive: MS SQL: failure when creating local temporary table

Created on 3 May 2021  ·  9Comments  ·  Source: hibernate/hibernate-reactive

Found the issue while running UnionSubclassInheritanceTest with MS SQL.

HR uses ReactiveIdTableSupport to generate SQL for creating local temporary table.

MS SQL expects local temporary table names to begin with a single hash sign:
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql#temporary-tables

bug

All 9 comments

Yeah it's because we're using ReactiveBulkIdStrategy instead of the thing returned by AbstractTransactSQLDialect.getDefaultMultiTableBulkIdStrategy(). It should be easy enough to fix. Don't worry too much about this for now.

@tsegismont it should be enough to change ReactiveIdTableSupport. generateIdTableName () as follows:

    @Override
    public String generateIdTableName(String baseName) {
        return (dialect instanceof SQLServerDialect ?  "#" : "ht_") + baseName;
    }

@gavinking thanks for the tip. I went with something slightly different (to keep the ht_ prefix) and also had to change the getCreateIdTableCommand method.

See https://github.com/tsegismont/hibernate-reactive/commit/84caabcefb4eb1a47e7e0c2d931584038d162393

I went with something slightly different (to keep the ht_ prefix)

Well I believe if you check Hibernate ORM (which we try to align with), it drops the ht_ prefix in the case of SQL Server, because the temporary tables have their own namespace.

@tsegismont can we close this one?

I shared some changes in a PR to @DavideD 's fork.

If these changes have been cherry-picked here then yes the issue can be closed.

Thanks @tsegismont, I will have a look at this today

Thanks guys.

Was this page helpful?
0 / 5 - 0 ratings