Microsoft SQL variant type error pops up when I run hibernate 5

Viewed 6538

Whenever I run my hibernate 5, I see this error:

ERROR: Could not fetch the SequenceInformation from the database
com.microsoft.sqlserver.jdbc.SQLServerException: The "variant" data type is not supported.

I've never heard of a "variant" data type before. Or is it a category of data types? Not sure.

I checked the data types in all my tables, and these are the ones that are there: bigint, bit, date, datetime, int, numeric, varbinary, and varchar.

Where could this error be coming from? Is there somewhere else I should check for variant types?

EDIT:

I ran this query select distinct data_type from INFORMATION_SCHEMA.COLUMNS to get all the data types in my database, and sql variant didn't show up. That's how I'm sure there isn't one.

Is there somewhere else this could be referenced?

EDIT 2:

A little bit more information on this. The application is a maven project. I created a normal java project and ran the same codes against the same database, and I didn't get any error about sql variant types.

So this issue seems to be tied to the hibernate dependency. I don't get it, really. This is the dependency I'm using:

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.4.0.Final</version>
        </dependency>
4 Answers

Alright. So, I checked the library I was using in my normal java application, and it's Hibernate 5.3.7. The one I'm using in my maven application is 5.4.0.

So I changed the hibernate library in my maven app to:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.3.7.Final</version>
    </dependency>

And now everything works. No complaints about some weird some weird Sql Variant type.

This issue also affects Hibernate search 5.11.0. You should use 5.10.5.Final.

Unfortunately, I don't have the proper credentials to raise this with the hibernate team on their issues tracker. Hopefully one of them will come across this post and address it. I know they're working on a hibernate search 6 and hibernate ORM 6, so that's good news!

My application is a spring-boot 2.2.7 with spring-data which has a dependency with hibernate-core 5.4.15.Final. I was using:

    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>6.2.2.jre8</version>
        <scope>test</scope>
    </dependency>

I tried upgrading mssql-jdbc to 8.3.1.jre8-preview but this error persisted.

After downgrading hibernate-core to 5.3.7 it fixed my problem.

Thanks for the tip @Akin_Glen

In my project MSSQL version 2017. springboot-parent version is 2.5.6. hibernate-core version is 5.4.32.Final. MSSQL Driver sqljdbc4 version 4.1 I get error when start project. I see there's an answer said change driver version ,then i try mssql-jdbc version 6.2.2.jre8,it's dosen't work. But version 9.4.1.jre8 it's worked solved the problem. enter image description here

Related