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>
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!
This issue is a bug in the MSSQL JDBC-Driver, see
https://github.com/microsoft/mssql-jdbc/pull/442
As mentioned in the changelog, this is fixed for versions >=6.3.2
Fixed sql_variant issue with String type #442
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With